From 32d9aef61f64ad2b806c83b38db1a61c4375563f Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 31 Jan 2024 15:37:12 +0100 Subject: [PATCH] Dropped creating global templates directory via compiler pass --- .../DependencyInjection/Compiler/TwigThemePass.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bundle/DependencyInjection/Compiler/TwigThemePass.php b/bundle/DependencyInjection/Compiler/TwigThemePass.php index 71ede9b..0404f4a 100644 --- a/bundle/DependencyInjection/Compiler/TwigThemePass.php +++ b/bundle/DependencyInjection/Compiler/TwigThemePass.php @@ -11,7 +11,6 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; /** @@ -27,10 +26,6 @@ public function process(ContainerBuilder $container) return; } - $globalViewsDir = $container->getParameter('twig.default_path'); - if (!is_dir($globalViewsDir)) { - (new Filesystem())->mkdir($globalViewsDir); - } $themesPathMap = [ '_override' => $container->getParameter('ezdesign.templates_override_paths'), ]; @@ -52,11 +47,11 @@ public function process(ContainerBuilder $container) $twigLoaderDef = $container->findDefinition('ezdesign.twig_theme_loader'); // Now look for themes at application level - $appLevelThemesDir = $globalViewsDir . '/themes'; + $appLevelThemesDir = $container->getParameter('twig.default_path') . '/themes'; if (is_dir($appLevelThemesDir)) { foreach ((new Finder())->directories()->in($appLevelThemesDir)->depth('== 0') as $directoryInfo) { $theme = $directoryInfo->getBasename(); - $themePaths = isset($themesPathMap[$theme]) ? $themesPathMap[$theme] : []; + $themePaths = $themesPathMap[$theme] ?? []; // Application level paths are always top priority. array_unshift($themePaths, $directoryInfo->getRealPath()); $themesPathMap[$theme] = $themePaths; @@ -91,8 +86,8 @@ public function process(ContainerBuilder $container) $container->setParameter( 'ezdesign.themes_list', array_unique( - array_merge($themesList, array_keys($themesPathMap)) - ) + array_merge($themesList, array_keys($themesPathMap)) + ) ); $container->setParameter('ezdesign.templates_path_map', $themesPathMap);