From 3cb2e5b7dd29587381d83e0d055303bf1869214b Mon Sep 17 00:00:00 2001 From: Pierre Rineau Date: Fri, 28 Apr 2017 12:25:29 +0200 Subject: [PATCH] Fixes twig bundle project root dir discovery --- .../Compiler/ExtensionPass.php | 17 ----------------- .../TwigBundle/Resources/config/templating.xml | 2 +- .../Bundle/TwigBundle/Resources/config/twig.xml | 2 +- .../DependencyInjection/TwigExtensionTest.php | 1 + src/Symfony/Bundle/TwigBundle/composer.json | 2 +- 5 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index b73af4461e7e..3e23f5a8a802 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -80,16 +80,13 @@ public function process(ContainerBuilder $container) $container->getDefinition('twig.extension.debug')->addTag('twig.extension'); } - $composerRootDir = $this->getComposerRootDir($container->getParameter('kernel.root_dir')); $twigLoader = $container->getDefinition('twig.loader.native_filesystem'); if ($container->has('templating')) { $loader = $container->getDefinition('twig.loader.filesystem'); $loader->setMethodCalls(array_merge($twigLoader->getMethodCalls(), $loader->getMethodCalls())); - $loader->replaceArgument(2, $composerRootDir); $twigLoader->clearTag('twig.loader'); } else { - $twigLoader->replaceArgument(1, $composerRootDir); $container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false)); } @@ -109,18 +106,4 @@ public function process(ContainerBuilder $container) $container->getDefinition('twig.extension.expression')->addTag('twig.extension'); } } - - private function getComposerRootDir($rootDir) - { - $dir = $rootDir; - while (!file_exists($dir.'/composer.json')) { - if ($dir === dirname($dir)) { - return $rootDir; - } - - $dir = dirname($dir); - } - - return $dir; - } } diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml index fae523eb6fd0..b9c1806221ed 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml @@ -7,7 +7,7 @@ - + %kernel.project_dir% diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 02717329c282..22ad287f7011 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -48,7 +48,7 @@ - + %kernel.project_dir% diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 4ff904dfe076..4d78b772655e 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -256,6 +256,7 @@ private function createContainer() $container = new ContainerBuilder(new ParameterBag(array( 'kernel.cache_dir' => __DIR__, 'kernel.root_dir' => __DIR__.'/Fixtures', + 'kernel.project_dir' => __DIR__, 'kernel.charset' => 'UTF-8', 'kernel.debug' => false, 'kernel.bundles' => array( diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index e645ca2015c1..63c0fefe5a02 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -20,7 +20,7 @@ "symfony/config": "~3.2", "symfony/twig-bridge": "^3.2.1", "symfony/http-foundation": "~2.8|~3.0", - "symfony/http-kernel": "~2.8.16|~3.1.9|^3.2.2", + "symfony/http-kernel": "^3.3", "twig/twig": "^1.32|^2.2" }, "require-dev": {