Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0a658c6

Browse filesBrowse files
committed
Add exclusive Twig namespace for bundles path
1 parent ad4bc6b commit 0a658c6
Copy full SHA for 0a658c6

File tree

3 files changed

+9
-0
lines changed
Filter options

3 files changed

+9
-0
lines changed

‎src/Symfony/Bundle/TwigBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
3.4.0
55
-----
66

7+
* added exclusive Twig namespace only for root bundles
78
* deprecated `Symfony\Bundle\TwigBundle\Command\DebugCommand`, use `Symfony\Bridge\Twig\Command\DebugCommand` instead
89
* deprecated relying on the `ContainerAwareInterface` implementation for `Symfony\Bundle\TwigBundle\Command\LintCommand`
910
* added option to configure default path templates (via `default_path`)

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ public function load(array $configs, ContainerBuilder $container)
130130
foreach ($bundle['paths'] as $path) {
131131
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
132132
}
133+
134+
// add exclusive namespace for root bundles only
135+
// to override a bundle template that also extends itself
136+
if (count($bundle['paths']) > 0 && 0 === count($bundle['parents'])) {
137+
// the last path must be the bundle views directory
138+
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array(end($bundle['paths']), '!'.$namespace));
139+
}
133140
}
134141

135142
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {

‎src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public function testTwigLoaderPaths($format)
198198
array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'),
199199
array(__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'),
200200
array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'),
201+
array(realpath(__DIR__.'/../..').'/Resources/views', '!Twig'),
201202
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
202203
array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
203204
array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.