8000 [TwigBundle] fixed usage when Templating is not installed by fabpot · Pull Request #21205 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBundle] fixed usage when Templating is not installed #21205

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
Jan 8, 2017

Conversation

fabpot
Copy link
Member
@fabpot fabpot commented Jan 8, 2017
Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets bug introduced in #20799
License MIT
Doc PR n/a

In #20799, the decoupling of the Templating definition means that the twig.loader.filesystem is not always defined, but used in Extension. So, this PR does the opposite as what was done before. Use twig.loader.native_filesystem by default and copy paths to twig.loader.filesystem when templating is used.

/cc @xabbuh

@@ -10,8 +10,6 @@
<tag name="twig.loader"/>
</service>

<service id="twig.loader" alias="twig.loader.filesystem" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed as handled by the loader pass.

@fabpot fabpot force-pushed the twig-bundle-hotfix branch 5 times, most recently from 70f172b to 8a49a0b Compare January 8, 2017 19:50
$loader->addTag('twig.loader');
$loader->setMethodCalls($container->getDefinition('twig.loader.filesystem')->getMethodCalls());
$twigLoader = $container->getDefinition('twig.loader.native_filesystem');
if ($container->has('templating')) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not checking for twig.loader.filesystem here?

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, done

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted

@fabpot fabpot force-pushed the twig-bundle-hotfix branch 2 times, most recently from 14d6eab to 8553d79 Compare January 8, 2017 20:17
@xabbuh
Copy link
Member
xabbuh commented Jan 8, 2017

Looks like we need to add some more checks to make sure that the Templating component is not only present, but that the templating config in FrameworkBundle is enabled too.

@fabpot fabpot force-pushed the twig-bundle-hotfix branch from 8553d79 to 6aa98d1 Compare January 8, 2017 20:32
@fabpot
Copy link
Member Author
fabpot commented Jan 8, 2017

That's why checking on 'templating' was better. Switched back, tests pass now.

@xabbuh
Copy link
Member
xabbuh commented Jan 8, 2017

Indeed, that's better.

@fabpot fabpot merged commit 6aa98d1 into symfony:2.7 Jan 8, 2017
fabpot added a commit that referenced this pull request Jan 8, 2017
…(fabpot)

This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBundle] fixed usage when Templating is not installed

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | bug introduced in #20799
| License       | MIT
| Doc PR        | n/a

In #20799, the decoupling of the Templating definition means that the `twig.loader.filesystem` is not always defined, but used in Extension. So, this PR does the opposite as what was done before. Use `twig.loader.native_filesystem` by default and copy paths to `twig.loader.filesystem` when templating is used.

/cc @xabbuh

Commits
-------

6aa98d1 [TwigBundle] fixed usage when Templating is not installed
@fabpot fabpot deleted the twig-bundle-hotfix branch January 8, 2017 21:24
@stof
Copy link
Member
stof commented Jan 9, 2017

@fabpot what about registering a loader resolving only the AppBundle:Default:index.html.twig location, and then always registering the native Twig loader for native syntaxes ? They don't really need to be in the same loader.

@fabpot
Copy link
Member Author
fabpot commented Jan 9, 2017

@stof Might be an idea, but it's done this way for performance optimization: it avoids having the chain loader.

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.

4 participants
0