Skip to content

Commit

Permalink
Fix lolautruche#20: Fatal if global themes directories don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
lolautruche committed Mar 27, 2017
1 parent 0ed9170 commit 20ea2a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions DependencyInjection/Compiler/AssetThemePass.php
Expand Up @@ -49,12 +49,14 @@ public function process(ContainerBuilder $container)

// Look for assets themes at application level (web/assets/themes).
$appLevelThemeDir = $container->getParameter('webroot_dir').'/assets/themes';
foreach ((new Finder())->directories()->in($appLevelThemeDir)->depth('== 0') as $directoryInfo) {
$theme = $directoryInfo->getBasename();
$themePaths = isset($themesPathMap[$theme]) ? $themesPathMap[$theme] : [];
// Application level paths are always top priority.
array_unshift($themePaths, 'assets/themes/'.$theme);
$themesPathMap[$theme] = $themePaths;
if (is_dir($appLevelThemeDir)) {
foreach ((new Finder())->directories()->in($appLevelThemeDir)->depth('== 0') as $directoryInfo) {
$theme = $directoryInfo->getBasename();
$themePaths = isset($themesPathMap[$theme]) ? $themesPathMap[$theme] : [];
// Application level paths are always top priority.
array_unshift($themePaths, 'assets/themes/'.$theme);
$themesPathMap[$theme] = $themePaths;
}
}

foreach ($themesPathMap as $theme => &$paths) {
Expand Down
14 changes: 8 additions & 6 deletions DependencyInjection/Compiler/TwigThemePass.php
Expand Up @@ -60,12 +60,14 @@ public function process(ContainerBuilder $container)
$twigLoaderDef = $container->findDefinition('ez_core_extra.twig_theme_loader');
// Now look for themes at application level (app/Resources/views/themes)
$appLevelThemesDir = $globalViewsDir.'/themes';
foreach ((new Finder())->directories()->in($appLevelThemesDir)->depth('== 0') as $directoryInfo) {
$theme = $directoryInfo->getBasename();
$themePaths = isset($themesPathMap[$theme]) ? $themesPathMap[$theme] : [];
// Application level paths are always top priority.
array_unshift($themePaths, $directoryInfo->getRealPath());
$themesPathMap[$theme] = $themePaths;
if (is_dir($appLevelThemesDir)) {
foreach ((new Finder())->directories()->in($appLevelThemesDir)->depth('== 0') as $directoryInfo) {
$theme = $directoryInfo->getBasename();
$themePaths = isset($themesPathMap[$theme]) ? $themesPathMap[$theme] : [];
// Application level paths are always top priority.
array_unshift($themePaths, $directoryInfo->getRealPath());
$themesPathMap[$theme] = $themePaths;
}
}

// De-duplicate the map
Expand Down

0 comments on commit 20ea2a7

Please sign in to comment.