From 2657f57d2924b42d5c51ad36f720085439e3473e Mon Sep 17 00:00:00 2001 From: Sander Verkuil Date: Fri, 18 May 2018 09:53:59 +0200 Subject: [PATCH] Fix BC with Symfony 2.8 LTS (#322) * If the container has the parameter project_dir use that one, otherwise use the root_dir * Use the Kernel Version ID instead --- DependencyInjection/LexikTranslationExtension.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/LexikTranslationExtension.php b/DependencyInjection/LexikTranslationExtension.php index 2a869ed8..3d573f30 100644 --- a/DependencyInjection/LexikTranslationExtension.php +++ b/DependencyInjection/LexikTranslationExtension.php @@ -138,9 +138,18 @@ public function prepend(ContainerBuilder $container) return; } + $rootDir = 'vendor/lexik/translation-bundle/Resources/views'; + + // Only symfony versions >= 3.3 include the kernel.project_dir parameter + if (Kernel::VERSION_ID >= 30300) { + $rootDir = '%kernel.project_dir%/'.$rootDir; + } else { + $rootDir = '%kernel.root_dir%/../'.$rootDir; + } + $container->prependExtensionConfig('twig', [ 'paths' => [ - '%kernel.project_dir%/vendor/lexik/translation-bundle/Resources/views' => 'LexikTranslationBundle' + $rootDir => 'LexikTranslationBundle' ] ]); }