From 1eb4fd8dcf0b4c579e7116d5938a97db976f7a24 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 28 Feb 2024 15:54:05 +0100 Subject: [PATCH] Dropped creating global templates directory via compiler pass For more details see https://github.com/ezsystems/ezplatform-design-engine/pull/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 --- .github/workflows/ci.yaml | 2 +- .../Compiler/AssetThemePass.php | 7 +++++-- .../Compiler/TwigThemePass.php | 16 +++++++--------- composer.json | 7 ++----- lib/Templating/TemplateNameResolverInterface.php | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d2fdba1..1e8c94e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: strategy: matrix: php: - - '8.0' + - '8.1' steps: - uses: actions/checkout@v2 diff --git a/bundle/DependencyInjection/Compiler/AssetThemePass.php b/bundle/DependencyInjection/Compiler/AssetThemePass.php index b042794..dc8497c 100644 --- a/bundle/DependencyInjection/Compiler/AssetThemePass.php +++ b/bundle/DependencyInjection/Compiler/AssetThemePass.php @@ -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') diff --git a/bundle/DependencyInjection/Compiler/TwigThemePass.php b/bundle/DependencyInjection/Compiler/TwigThemePass.php index 00efb1d..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; @@ -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); diff --git a/composer.json b/composer.json index 320b329..38df2eb 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -58,8 +57,6 @@ "lolautruche/ez-core-extra-bundle": "<2.0" }, "config": { - "allow-plugins": { - "composer/package-versions-deprecated": true - } + "allow-plugins": false } } diff --git a/lib/Templating/TemplateNameResolverInterface.php b/lib/Templating/TemplateNameResolverInterface.php index 61142d8..b111881 100644 --- a/lib/Templating/TemplateNameResolverInterface.php +++ b/lib/Templating/TemplateNameResolverInterface.php @@ -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.