Add exclusive Twig namespace for bundles path
This commit is contained in:
parent
ad4bc6b647
commit
0a658c6eef
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
3.4.0
|
3.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* added exclusive Twig namespace only for root bundles
|
||||||
* deprecated `Symfony\Bundle\TwigBundle\Command\DebugCommand`, use `Symfony\Bridge\Twig\Command\DebugCommand` instead
|
* deprecated `Symfony\Bundle\TwigBundle\Command\DebugCommand`, use `Symfony\Bridge\Twig\Command\DebugCommand` instead
|
||||||
* deprecated relying on the `ContainerAwareInterface` implementation for `Symfony\Bundle\TwigBundle\Command\LintCommand`
|
* deprecated relying on the `ContainerAwareInterface` implementation for `Symfony\Bundle\TwigBundle\Command\LintCommand`
|
||||||
* added option to configure default path templates (via `default_path`)
|
* added option to configure default path templates (via `default_path`)
|
||||||
|
@ -130,6 +130,13 @@ class TwigExtension extends Extension
|
|||||||
foreach ($bundle['paths'] as $path) {
|
foreach ($bundle['paths'] as $path) {
|
||||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
|
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add exclusive namespace for root bundles only
|
||||||
|
// to override a bundle template that also extends itself
|
||||||
|
if (count($bundle['paths']) > 0 && 0 === count($bundle['parents'])) {
|
||||||
|
// the last path must be the bundle views directory
|
||||||
|
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array(end($bundle['paths']), '!'.$namespace));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
|
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
|
||||||
|
@ -198,6 +198,7 @@ class TwigExtensionTest extends TestCase
|
|||||||
array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'),
|
array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'),
|
||||||
array(__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'),
|
array(__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'),
|
||||||
array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'),
|
array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'),
|
||||||
|
array(realpath(__DIR__.'/../..').'/Resources/views', '!Twig'),
|
||||||
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
|
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
|
||||||
array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
|
array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
|
||||||
array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'),
|
array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'),
|
||||||
|
Reference in New Issue
Block a user