Skip to content

Commit

Permalink
Dropped creating global templates directory via compiler pass
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Jan 31, 2024
1 parent 4978aad commit 32d9aef
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions bundle/DependencyInjection/Compiler/TwigThemePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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'),
];
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 32d9aef

Please sign in to comment.