Skip to content

Commit

Permalink
Dropped creating global templates directory via compiler pass
Browse files Browse the repository at this point in the history
For more details see ezsystems/ezplatform-design-engine#47

Key changes:

* Dropped creating global templates directory via compiler pass

* [CS] Updated CS fixer to rely on ibexa/code-style

* [CS] Aligned code style with the updated rules

* [Composer] Disallowed plugins
  • Loading branch information
alongosz authored Feb 28, 2024
1 parent d48fc7e commit 1eb4fd8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
php:
- '8.0'
- '8.1'
steps:
- uses: actions/checkout@v2

Expand Down
7 changes: 5 additions & 2 deletions bundle/DependencyInjection/Compiler/AssetThemePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ public function process(ContainerBuilder $container)
}

$themesList = $container->getParameter('ezdesign.themes_list');
$container->setParameter('ezdesign.themes_list', array_unique(
array_merge($themesList, array_keys($themesPathMap)))
$container->setParameter(
'ezdesign.themes_list',
array_unique(
array_merge($themesList, array_keys($themesPathMap))
)
);
$container->setParameter('ezdesign.assets_path_map', $pathsByDesign);
$container->findDefinition('ezdesign.asset_path_resolver')
Expand Down
16 changes: 7 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 @@ -88,8 +83,11 @@ public function process(ContainerBuilder $container)
}

$themesList = $container->getParameter('ezdesign.themes_list');
$container->setParameter('ezdesign.themes_list', array_unique(
array_merge($themesList, array_keys($themesPathMap)))
$container->setParameter(
'ezdesign.themes_list',
array_unique(
array_merge($themesList, array_keys($themesPathMap))
)
);
$container->setParameter('ezdesign.templates_path_map', $themesPathMap);

Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
},
"require-dev": {
"ezsystems/doctrine-dbal-schema": "^1.0@dev",
"ezsystems/ezplatform-code-style": "^1.0",
"ibexa/code-style": "^1.0",
"phpunit/phpunit": "^8.1",
"friendsofphp/php-cs-fixer": "^2.16.0",
"mikey179/vfsstream": "^1.6"
},
"autoload": {
Expand Down Expand Up @@ -58,8 +57,6 @@
"lolautruche/ez-core-extra-bundle": "<2.0"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true
}
"allow-plugins": false
}
}
2 changes: 1 addition & 1 deletion lib/Templating/TemplateNameResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
interface TemplateNameResolverInterface
{
const EZ_DESIGN_NAMESPACE = 'ezdesign';
public const EZ_DESIGN_NAMESPACE = 'ezdesign';

/**
* Resolves provided template name within current design and returns properly namespaced template name.
Expand Down

0 comments on commit 1eb4fd8

Please sign in to comment.