Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Removed calls to Twig\Environment::loadTemplate() #33273

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

Merged
merged 1 commit into from
Aug 21, 2019

Conversation

derrabus
Copy link
Member

Q A
Branch? 4.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

This PR prepares #33039. Twig 3 does not have the loadTemplate() anymore, so this PR replaces calls to that method.

@@ -154,7 +154,7 @@ protected function loadResourcesFromTheme($cacheKey, &$theme)
{
if (!$theme instanceof Template) {
/* @var Template $theme */
$theme = $this->environment->loadTemplate($theme);
$theme = $this->environment->load($theme)->unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot the reason why we need to unwrap here is that we rely on the internal getBlocks function of the Template class. We don't only want to use the block names, so the non-internal getBlockNames is not enough for us (we are also relying on the internal displayBlock signature which has more arguments)

@fabpot
Copy link
Member

fabpot commented Aug 21, 2019

@stof is right, I read too fast. We should avoid to unwrap when not strictly needed.

@stof
Copy link
Member

stof commented Aug 21, 2019

the only place needing to unwrap is the form renderer engine, because it relies on internal Twig APIs to manipulate blocks (which is bad news, as there is no BC guarantee for them)

@nicolas-grekas nicolas-grekas added this to the next milestone Aug 21, 2019
@derrabus derrabus force-pushed the improvement/twig-3-backports branch 2 times, most recently from 2fcb90e to b792255 Compare August 21, 2019 11:16
@derrabus derrabus force-pushed the improvement/twig-3-backports branch from b792255 to ea9e375 Compare August 21, 2019 11:26
@derrabus
Copy link
Member Author

I can't do much about the unwrapping in TwigRendererEngine and would advise against changing TwigEngine: it's a deprecated class anyway and we're risking a BC break.

Status: needs review

@derrabus
Copy link
Member Author

CI failure seems to be an internal hiccup at Travis.

@fabpot
Copy link
Member

fabpot commented Aug 21, 2019

Thank you @derrabus.

fabpot added a commit that referenced this pull request Aug 21, 2019
This PR was merged into the 4.4 branch.

Discussion
----------

Removed calls to Twig\Environment::loadTemplate()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

This PR prepares #33039. Twig 3 does not have the `loadTemplate()` anymore, so this PR replaces calls to that method.

Commits
-------

ea9e375 Removed calls to Twig\Environment::loadTemplate().
@fabpot fabpot merged commit ea9e375 into symfony:4.4 Aug 21, 2019
@derrabus derrabus deleted the improvement/twig-3-backports branch August 21, 2019 11:52
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants