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

Skip to content

Issue 7373 #7375

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 2 commits into from
Mar 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ public function process(ContainerBuilder $container)
$container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form'));
}

if (false === $container->has('translator')) {
if ($container->has('translator')) {
$container->getDefinition('twig.extension.trans')->addTag('twig.extension');
}

if ($container->has('router')) {
$container->getDefinition('twig.extension.routing')->addTag('twig.extension');
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if it's possible or better. But I think adding a tag in the compiler pass is strange and counter-intuitive.
Would it not be better to remove the definition of the service when the service cannot be used? Like
$container->removeDefinition('twig.extension.routing')?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the first place, I loaded service definition (with separate XMLs) only if dependencies were satisfied. Then @stof told me to do it this way because "it avoids breaking other compiler passes trying to access the extension".

}

if ($container->has('fragment.handler')) {
$container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension');
}
}
}
2 changes: 0 additions & 2 deletions src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
</service>

<service id="twig.extension.routing" class="%twig.extension.routing.class%" public="false">
<tag name="twig.extension" />
<argument type="service" id="router" />
</service>

Expand All @@ -88,7 +87,6 @@
</service>

<service id="twig.extension.httpkernel" class="%twig.extension.httpkernel.class%" public="false">
<tag name="twig.extension" />
<argument type="service" id="fragment.handler" />
</service>

Expand Down