-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WIP] #15502 Make template shortcuts be usable without Templating component #15620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Koc
commented
Aug 26, 2015
Q | A |
---|---|
Bug fix? | yes |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | ? |
Fixed tickets | #15502 |
License | MIT |
Doc PR | - |
You should add this change to the CHANGELOG.md |
👍 |
👍 but some tiny tests to ensure these methods keep being called would be good. |
@Tobion can you give advice, maybe some piece of code how to do this? Bootstrap kernel without templating - where should I do it? |
I don't mean functional tests but unit tests. We already have unit tests for this class. Just mock the container and ensure the methods are called. |
$twig = $this->container->get('twig'); | ||
|
||
$callback = function () use ($twig, $view, $parameters) { | ||
$twig->loadTemplate($view)->display($parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use $twig->display()
here rather than the internal implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadTemplate() is public, so it's not internal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what's the point of using the more verbose version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one less method call ;)
doesn't really matter to me. I'm fine with both
And if the if ($this->container->has('templating')) {
// use the templating component
} else if ($this->container->has('twig')) {
// use twig
} else {
throw new \LogicException('You can not use the XXX method if the Templating Component or the Twig Bundle are not available.');
} |
Thank you @Koc. |
I've reverted the tests |