diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d2fdba1..11a80ac 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,7 +42,6 @@ jobs: fail-fast: false matrix: php: - - '7.3' - '7.4' - '8.0' - '8.1' diff --git a/.gitignore b/.gitignore index d0ffc03..a5a6b64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /vendor/ composer.lock -.php_cs.cache +.php-cs-fixer.cache /.phpunit.result.cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index a7ed9d8..da33ee0 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -17,10 +17,11 @@ ->buildConfig() ->setFinder( PhpCsFixer\Finder::create() - ->in(__DIR__) - ->exclude([ - 'vendor', - 'doc', - ]) + ->in( + array_filter([ + __DIR__ . '/src', + __DIR__ . '/tests', + ], 'is_dir') + ) ->files()->name('*.php') ); diff --git a/bundle/Resources/config/default_settings.yaml b/bundle/Resources/config/default_settings.yaml deleted file mode 100644 index ac1f879..0000000 --- a/bundle/Resources/config/default_settings.yaml +++ /dev/null @@ -1,2 +0,0 @@ -parameters: - ezsettings.default.design: standard diff --git a/bundle/Resources/config/services.yaml b/bundle/Resources/config/services.yaml deleted file mode 100644 index e8fb8cc..0000000 --- a/bundle/Resources/config/services.yaml +++ /dev/null @@ -1,54 +0,0 @@ -parameters: - ezdesign.themes_list: [] - ezdesign.design_list: [] - ezdesign.templates_path_map: {} - ezdesign.assets_path_map: {} - ezdesign.templates_override_paths: [] - ezdesign.assets_override_paths: [] - ezdesign.asset_resolved_paths: {} - ezdesign.asset_resolution.disabled: '%kernel.debug%' - ezdesign.phpstorm.enabled: true - -services: - ezdesign.template_name_resolver: - class: EzSystems\EzPlatformDesignEngine\Templating\ThemeTemplateNameResolver - arguments: ["@ezpublish.config.resolver"] - - ezdesign.template_path_registry: - class: EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistry - arguments: ["%kernel.project_dir%"] - - ezdesign.twig_theme_loader: - class: EzSystems\EzPlatformDesignEngine\Templating\Twig\TwigThemeLoader - public: false - decorates: twig.loader.native_filesystem - arguments: - - "@ezdesign.template_name_resolver" - - "@ezdesign.template_path_registry" - - "@ezdesign.twig_theme_loader.inner" - - ezdesign.asset_path_resolver.runtime: - class: EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolver - arguments: - - "%ezdesign.assets_path_map%" - - "%webroot_dir%" - public: false - - ezdesign.asset_path_resolver.provisioned: - class: EzSystems\EzPlatformDesignEngine\Asset\ProvisionedPathResolver - arguments: - - '%ezdesign.asset_resolved_paths%' - - '@ezdesign.asset_path_resolver.runtime' - - '%webroot_dir%' - public: false - - ezdesign.asset_path_resolver: - alias: ezdesign.asset_path_resolver.runtime - - ezdesign.asset_theme_package: - class: EzSystems\EzPlatformDesignEngine\Asset\ThemePackage - arguments: - - "@ezdesign.asset_path_resolver" - - "@assets._default_package" - calls: - - [setConfigResolver, ["@ezpublish.config.resolver"]] diff --git a/composer.json b/composer.json index 8e7d8a1..94cd66a 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,24 @@ { - "name": "ezsystems/ezplatform-design-engine", - "description": "Design fallback mechanism for eZ Platform", + "name": "ibexa/design-engine", + "description": "Design fallback mechanism for Ibexa", "license": "GPL-2.0-only", - "type": "ezplatform-bundle", + "type": "ibexa-bundle", + "replace": { + "ezsystems/ezplatform-design-engine": "*" + }, "authors": [ { "name": "Jerome Vieilledent", "email": "jerome@vieilledent.fr" }, { - "name": "eZ Systems dev team", - "email": "dev-team@ez.no" + "name": "Ibexa Engineering & Community", + "homepage": "https://www.ibexa.co/products" } ], "require": { - "ezsystems/ezplatform-kernel": "^1.0@dev", + "php": "^7.4 || ^8.0", + "ibexa/core": "^4.0@dev", "twig/twig": "^3.0", "symfony/dependency-injection": "^5.0", "symfony/http-kernel": "^5.0", @@ -26,32 +30,37 @@ "symfony/templating": "^5.0" }, "require-dev": { - "ezsystems/doctrine-dbal-schema": "^1.0@dev", - "ezsystems/ezplatform-code-style": "^1.0", + "ibexa/code-style": "^1.0", + "ibexa/doctrine-schema": "^4.0@dev", "phpunit/phpunit": "^8.1", - "friendsofphp/php-cs-fixer": "^2.16.0", + "friendsofphp/php-cs-fixer": "^3.0", "mikey179/vfsstream": "^1.6" }, "autoload": { "psr-4": { - "EzSystems\\EzPlatformDesignEngine\\": "lib", - "EzSystems\\EzPlatformDesignEngineBundle\\": "bundle" + "Ibexa\\DesignEngine\\": "src/lib/", + "Ibexa\\Bundle\\DesignEngine\\": "src/bundle/", + "Ibexa\\Contracts\\DesignEngine\\": "src/contracts/", + "EzSystems\\EzPlatformDesignEngine\\": "src/lib/", + "EzSystems\\EzPlatformDesignEngineBundle\\": "src/bundle/" } }, "autoload-dev": { "psr-4": { + "Ibexa\\Tests\\Bundle\\DesignEngine\\": "tests/bundle/", + "Ibexa\\Tests\\DesignEngine\\": "tests/lib/", "EzSystems\\EzPlatformDesignEngine\\Tests\\": "tests/lib", "EzSystems\\EzPlatformDesignEngineBundle\\Tests\\": "tests/bundle" } }, "scripts": { - "fix-cs": "php-cs-fixer fix -v --show-progress=estimating", + "fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots", "check-cs": "@fix-cs --dry-run", "test": "phpunit" }, "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-main": "4.0.x-dev" } }, "conflict": { diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index 5866073..0000000 --- a/doc/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# EzPlatformDesignEngine documentation - -This feature enables you to provide design themes for your eZ application, with an automatic fallback system. -It is very similar to the [eZ Publish legacy design fallback system](https://doc.ez.no/eZ-Publish/Technical-manual/5.x/Concepts-and-basics/Designs/Design-combinations). - -When you call a given template or asset, the system will look for it in the first configured theme. -If it cannot be found, the system will fall back to all other configured themes for your current SiteAccess. - -Under the hood, the theming system uses Twig namespaces. As such, Twig is the only supported template engine. -For assets, the system uses the Symfony Asset component with asset packages. - -## Terminology - -- **Theme**: Labeled collection of templates and assets. - - Typically a directory containing templates. For example, templates located under `templates/themes/my_theme` - or `src/AppBundle/Resources/views/themes/my_theme` are part of `my_theme` theme. -- **Design**: Collection of themes. - - The order of themes within a design is important as it defines the fallback order. - A design is identified with a name. One design can be used per SiteAccess. - -## Configuration - -To define and use a design, you need to: - -1. Declare it, with a name and a collection of themes to use -1. Use it for your SiteAccess - -Here is a simple example: - -```yaml -# ezplatform.yml -ezdesign: - # You declare all available designs under "design_list". - design_list: - # my_design will be composed of "theme1" and "theme2" - # "theme1" will be tried first. If the template cannot be found in "theme1", "theme2" will be tried out. - my_design: [theme1, theme2] - -ezpublish: - # ... - system: - my_siteaccess: - # my_siteaccess will use "my_design" - design: my_design -``` - -> **Note**: Default design for a SiteAccess is `standard` which contains no themes. -> If you use the `@ezdesign` Twig namespace and/or the `ezdesign` asset package, the system will always fall back to -> application level and override directories for templates/assets lookup. - -## Usage - -- [Usage with templates](templates.md) -- [Usage with assets](assets.md) - -## Referencing current design - -It is possible to reference current design in order to inject it into a service. -To do so, you just need to reference the `$design$` dynamic setting: - -```yaml -services: - my_service: - class: Foo\Bar - arguments: ["$design$"] -``` - -It is also possible to use the `ConfigResolver` service (`ezpublish.config.resolver`): - -```php -// In a controller -$currentDesign = $this->getConfigResolver->getParameter('design'); -``` diff --git a/doc/assets.md b/doc/assets.md deleted file mode 100644 index b1b65b4..0000000 --- a/doc/assets.md +++ /dev/null @@ -1,58 +0,0 @@ -# Design usage with assets - -For assets, a special **`ezdesign` asset package** is available. - -```jinja - - - - -foo -``` - -Using the `ezdesign` package will resolve current design with theme fallback. - -By convention, an asset theme directory can be located in: -- `/Resources/public/themes/` -- `web/assets/themes/` - -Typical paths can be for example: -- `/Resources/public/themes/foo/` => Assets will be part of the `foo` theme. -- `/Resources/public/themes/bar/` => Assets will be part of the `bar` theme. -- `web/assets/themes/biz/` => Assets will be part of the `biz` theme. - -It is also possible to use `web/assets` as a global override directory. -If called asset is present **directly under this directory**, it will always be considered first. - -> **Important**: You must have *installed* your assets with `assets:install` command, so that your public resources are -*installed* into the `web/` directory. - -## Fallback order - -The default fallback order is: -- Application assets directory: `web/assets/` -- Application theme directory: `web/assets/themes//` -- Bundle theme directory: `web/bundles//themes//` - -Calling `asset("js/foo.js", "ezdesign")` can for example be resolved to `web/bundles/app/themes/my_theme/js/foo.js`. - -## Performance and asset resolution - -When using themes, paths for assets are resolved at runtime. -This is due to how the Symfony Asset component is integrated with Twig. -This can cause significant performance impact because of I/O calls when looping over all potential theme directories, -especially when using a lot of different designs and themes. - -To work around this issue, assets resolution can be provisioned at compilation time. -Provisioning is the **default behavior in non-debug mode** (e.g. `prod` environment). -In debug mode (e.g. `dev` environment), assets are being resolved at runtime. - -This behavior can however be controlled by the `disable_assets_pre_resolution` setting. - -```yaml -# ezplatform_prod.yml -ezdesign: - # Force runtime resolution - # Default value is '%kernel.debug%' - disable_assets_pre_resolution: true -``` diff --git a/doc/templates.md b/doc/templates.md deleted file mode 100644 index 3257a56..0000000 --- a/doc/templates.md +++ /dev/null @@ -1,108 +0,0 @@ -# Design usage with templates - -By convention, a theme directory must be located under `/Resources/views/themes/` or global -`templates/themes/` directories. - -Typical paths can be for example: -- `templates/themes/foo/` => Templates will be part of the `foo` theme. -- `templates/themes/bar/` => Templates will be part of the `bar` theme. -- `src/AppBundle/Resources/views/themes/foo/` => Templates will be part of the `foo`theme. -- `src/Acme/TestBundle/Resources/views/themes/the_best/` => Templates will be part of `the_best` theme. - -In order to use the configured design with templates, you need to use **`@ezdesign`** special **Twig namespace**. - -```jinja -{# Will load 'some_template.html.twig' directly under one of the specified theme directories #} -{{ include("@ezdesign/some_template.html.twig") }} - -{# Will load 'another_template.html.twig', located under 'full/' directory, which is located under one of the specified theme directories #} -{{ include("@ezdesign/full/another_template.html.twig") }} -``` - -You can also use `@ezdesign` notation in your eZ template selection rules: - -```yaml -ezpublish: - system: - my_siteaccess: - content_view: - full: - home: - template: "@ezdesign/full/home.html.twig" -``` - -> You may also use this notation in controllers. - -## Fallback order - -The default fallback order is: -- Application theme directory: `templates/themes//` -- Bundle theme directory: `src//Resources/views/themes//` - -Prior to version 2.0 of this package, `templates` was the top-level global override directory. -This behavior is not recommended as it could affect both core features and third party bundles -which already use `@ezdesign`. However, if still needed, it can be achieved by the following configuration: - -```yaml -ezdesign: - templates_override_paths: - - '%kernel.project_dir%/templates' -``` - -> Bundle fallback order is the instantiation order in `AppKernel`. - -### Additional theme paths - -In addition to the convention described above, it is also possible to add arbitrary Twig template directories to a theme -from configuration. This can be useful when you want to define templates from third-party bundles as part of one of your -themes, or when upgrading your application in order to use eZ Platform design engine, when your existing templates -are not yet following the convention. - -```yaml -ezdesign: - design_list: - my_design: [my_theme, some_other_theme] - templates_theme_paths: - # FOSUserBundle templates will be part of "my_theme" theme - my_theme: - - '%kernel.project_dir%/vendor/friendsofsymfony/user-bundle/Resources/views' -``` - -> **Paths precedence**: Directories following the convention will **always** have precedence over the ones defined -> in config. This ensures that it is always possible to override a template from the application. - -### Additional override paths - -It is possible to add additional global override directories. - -```yaml -ezdesign: - templates_override_paths: - - "%kernel.project_dir%/another_override_directory" - - "/some/other/directory" -``` - -## PHPStorm support - -`@ezdesign` Twig namespace is a *virtual* namespace, and as such is not automatically recognized by PHPStorm Symfony plugin -for `goto` actions. - -`EzPlatformDesignEngine` will generate a `ide-twig.json` file which will contain all detected theme paths for templates in your project. -It is activated by default in debug mode (`%kernel.debug%`). - -By default, this config file will be stored at your project root (`%kernel.project_dir%`), but you can customize the path -if your PHPStorm project root doesn't match your Symfony project root. - -> Note: `ide-twig.json` **must** be stored at your PHPStorm project root. - -Default config: -```yaml -ezdesign: - phpstorm: - - # Activates PHPStorm support - enabled: '%kernel.debug%' - - # Path where to store PHPStorm configuration file for additional Twig namespaces (ide-twig.json). - twig_config_path: '%kernel.project_dir%' -``` diff --git a/doc/upgrade/UPGRADE-2.0.md b/doc/upgrade/UPGRADE-2.0.md deleted file mode 100644 index 60f8fd2..0000000 --- a/doc/upgrade/UPGRADE-2.0.md +++ /dev/null @@ -1,17 +0,0 @@ -# Upgrading eZ Design Engine to v2.0 - -## Backward incompatible changes - -### Global override directory - -The `app/Resources/views` project directory is no longer a global override directory for all -Designs and Themes. Using it is not recommended as it can lead to accidental overriding of core or -third party bundle templates which also use `@ezdesign` and share the same name. - -However, if still needed, it can be achieved by the following configuration: - -```yaml -ezdesign: - templates_override_paths: - - '%kernel.project_dir%%/templates' -``` diff --git a/lib/DesignAwareInterface.php b/lib/DesignAwareInterface.php deleted file mode 100644 index 2486779..0000000 --- a/lib/DesignAwareInterface.php +++ /dev/null @@ -1,17 +0,0 @@ -configResolver = $configResolver; - } - - /** - * Returns the name of the current design, in the current context (i.e. SiteAccess). - * - * @return string - */ - private function getCurrentDesign() - { - return $this->configResolver->getParameter('design'); - } - - public function resolveTemplateName($name) - { - if (!$this->isTemplateDesignNamespaced($name)) { - return $name; - } elseif (isset($this->resolvedTemplateNames[$name])) { - return $this->resolvedTemplateNames[$name]; - } - - return $this->resolvedTemplateNames[$name] = str_replace('@' . self::EZ_DESIGN_NAMESPACE, '@' . $this->getCurrentDesign(), $name); - } - - public function isTemplateDesignNamespaced($name) - { - return (strpos($name, '@' . self::EZ_DESIGN_NAMESPACE) !== false) || (strpos($name, '@' . $this->getCurrentDesign()) !== false); - } -} diff --git a/phpunit.xml b/phpunit.xml index 78bdec5..f1881ce 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -12,7 +12,7 @@ > - + ./tests diff --git a/bundle/DataCollector/TwigDataCollector.php b/src/bundle/DataCollector/TwigDataCollector.php similarity index 88% rename from bundle/DataCollector/TwigDataCollector.php rename to src/bundle/DataCollector/TwigDataCollector.php index 8d177f0..270cb60 100644 --- a/bundle/DataCollector/TwigDataCollector.php +++ b/src/bundle/DataCollector/TwigDataCollector.php @@ -4,9 +4,9 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle\DataCollector; +namespace Ibexa\Bundle\DesignEngine\DataCollector; -use EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistryInterface; +use Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface; use Symfony\Bridge\Twig\DataCollector\TwigDataCollector as BaseCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -17,7 +17,7 @@ class TwigDataCollector extends BaseCollector implements LateDataCollectorInterface { /** - * @var \EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistryInterface + * @var \Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface */ private $templatePathRegistry; @@ -90,3 +90,5 @@ public function getProfile() return $profile; } } + +class_alias(TwigDataCollector::class, 'EzSystems\EzPlatformDesignEngineBundle\DataCollector\TwigDataCollector'); diff --git a/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php b/src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php similarity index 61% rename from bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php rename to src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php index b246dc3..f8e8858 100644 --- a/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php +++ b/src/bundle/DependencyInjection/Compiler/AssetPathResolutionPass.php @@ -4,9 +4,10 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler; +namespace Ibexa\Bundle\DesignEngine\DependencyInjection\Compiler; -use EzSystems\EzPlatformDesignEngine\Asset\AssetPathProvisionerInterface; +use Ibexa\DesignEngine\Asset\AssetPathProvisionerInterface; +use Ibexa\DesignEngine\Asset\ProvisionedPathResolver; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -23,18 +24,18 @@ class AssetPathResolutionPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - if ($container->getParameter('ezdesign.asset_resolution.disabled')) { + if ($container->getParameter('ibexa.design.assets.resolution.disabled')) { return; } $resolvedPathsByDesign = $this->preResolveAssetsPaths( - $container->get('ezdesign.asset_path_resolver.provisioned'), - $container->getParameter('ezdesign.assets_path_map') + $container->get(ProvisionedPathResolver::class), + $container->getParameter('ibexa.design.assets.path_map') ); - $container->setParameter('ezdesign.asset_resolved_paths', $resolvedPathsByDesign); - $container->findDefinition('ezdesign.asset_path_resolver.provisioned')->replaceArgument(0, $resolvedPathsByDesign); - $container->setAlias('ezdesign.asset_path_resolver', new Alias('ezdesign.asset_path_resolver.provisioned')); + $container->setParameter('ibexa.design.assets.resolved_paths', $resolvedPathsByDesign); + $container->findDefinition(ProvisionedPathResolver::class)->replaceArgument(0, $resolvedPathsByDesign); + $container->setAlias('ibexadesign.asset_path_resolver', new Alias(ProvisionedPathResolver::class)); } private function preResolveAssetsPaths(AssetPathProvisionerInterface $provisioner, array $designPathMap) @@ -47,3 +48,5 @@ private function preResolveAssetsPaths(AssetPathProvisionerInterface $provisione return $resolvedPathsByDesign; } } + +class_alias(AssetPathResolutionPass::class, 'EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler\AssetPathResolutionPass'); diff --git a/bundle/DependencyInjection/Compiler/AssetThemePass.php b/src/bundle/DependencyInjection/Compiler/AssetThemePass.php similarity index 75% rename from bundle/DependencyInjection/Compiler/AssetThemePass.php rename to src/bundle/DependencyInjection/Compiler/AssetThemePass.php index b042794..78a34e4 100644 --- a/bundle/DependencyInjection/Compiler/AssetThemePass.php +++ b/src/bundle/DependencyInjection/Compiler/AssetThemePass.php @@ -4,8 +4,10 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler; +namespace Ibexa\Bundle\DesignEngine\DependencyInjection\Compiler; +use Ibexa\Contracts\DesignEngine\DesignAwareInterface; +use Ibexa\DesignEngine\Asset\ThemePackage; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Finder\Finder; @@ -21,7 +23,7 @@ public function process(ContainerBuilder $container) $themesPathMap = [ '_override' => array_merge( ['assets'], - $container->getParameter('ezdesign.assets_override_paths') + $container->getParameter('ibexa.design.assets.override_paths') ), ]; $finder = new Finder(); @@ -59,7 +61,7 @@ public function process(ContainerBuilder $container) } $pathsByDesign = []; - foreach ($container->getParameter('ezdesign.design_list') as $designName => $themeFallback) { + foreach ($container->getParameter('ibexa.design.list') as $designName => $themeFallback) { // Always add _override theme first. array_unshift($themeFallback, '_override'); foreach ($themeFallback as $theme) { @@ -74,14 +76,19 @@ public function process(ContainerBuilder $container) } } - $themesList = $container->getParameter('ezdesign.themes_list'); - $container->setParameter('ezdesign.themes_list', array_unique( - array_merge($themesList, array_keys($themesPathMap))) + $themesList = $container->getParameter('ibexa.design.themes.list'); + $container->setParameter( + 'ibexa.design.themes.list', + array_unique( + array_merge($themesList, array_keys($themesPathMap)) + ) ); - $container->setParameter('ezdesign.assets_path_map', $pathsByDesign); - $container->findDefinition('ezdesign.asset_path_resolver') + $container->setParameter('ibexa.design.assets.path_map', $pathsByDesign); + $container->findDefinition('ibexadesign.asset_path_resolver') ->replaceArgument(0, $pathsByDesign); $container->findDefinition('assets.packages') - ->addMethodCall('addPackage', ['ezdesign', $container->findDefinition('ezdesign.asset_theme_package')]); + ->addMethodCall('addPackage', [DesignAwareInterface::DESIGN_NAMESPACE, $container->findDefinition(ThemePackage::class)]); } } + +class_alias(AssetThemePass::class, 'EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler\AssetThemePass'); diff --git a/bundle/DependencyInjection/Compiler/TwigThemePass.php b/src/bundle/DependencyInjection/Compiler/TwigThemePass.php similarity index 76% rename from bundle/DependencyInjection/Compiler/TwigThemePass.php rename to src/bundle/DependencyInjection/Compiler/TwigThemePass.php index 00efb1d..ee5ce3b 100644 --- a/bundle/DependencyInjection/Compiler/TwigThemePass.php +++ b/src/bundle/DependencyInjection/Compiler/TwigThemePass.php @@ -4,9 +4,11 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler; +namespace Ibexa\Bundle\DesignEngine\DependencyInjection\Compiler; -use EzSystems\EzPlatformDesignEngineBundle\DataCollector\TwigDataCollector; +use Ibexa\Bundle\DesignEngine\DataCollector\TwigDataCollector; +use Ibexa\DesignEngine\Templating\TemplatePathRegistry; +use Ibexa\DesignEngine\Templating\Twig\TwigThemeLoader; use ReflectionClass; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -23,7 +25,7 @@ class TwigThemePass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - if (!($container->hasParameter('kernel.bundles') && $container->hasDefinition('ezdesign.twig_theme_loader'))) { + if (!($container->hasParameter('kernel.bundles') && $container->hasDefinition(TwigThemeLoader::class))) { return; } @@ -32,7 +34,7 @@ public function process(ContainerBuilder $container) (new Filesystem())->mkdir($globalViewsDir); } $themesPathMap = [ - '_override' => $container->getParameter('ezdesign.templates_override_paths'), + '_override' => $container->getParameter('ibexa.design.templates.override_paths'), ]; $finder = new Finder(); // Look for themes in bundles. @@ -50,7 +52,7 @@ public function process(ContainerBuilder $container) } } - $twigLoaderDef = $container->findDefinition('ezdesign.twig_theme_loader'); + $twigLoaderDef = $container->findDefinition(TwigThemeLoader::class); // Now look for themes at application level $appLevelThemesDir = $globalViewsDir . '/themes'; if (is_dir($appLevelThemesDir)) { @@ -65,14 +67,14 @@ public function process(ContainerBuilder $container) // Now merge with already configured template theme paths // Template theme paths defined via config will always have less priority than convention based paths - $themesPathMap = array_merge_recursive($themesPathMap, $container->getParameter('ezdesign.templates_path_map')); + $themesPathMap = array_merge_recursive($themesPathMap, $container->getParameter('ibexa.design.templates.path_map')); // De-duplicate the map foreach ($themesPathMap as $theme => &$paths) { $paths = array_unique($paths); } - foreach ($container->getParameter('ezdesign.design_list') as $designName => $themeFallback) { + foreach ($container->getParameter('ibexa.design.list') as $designName => $themeFallback) { // Always add _override theme first. array_unshift($themeFallback, '_override'); foreach ($themeFallback as $theme) { @@ -87,11 +89,14 @@ public function process(ContainerBuilder $container) } } - $themesList = $container->getParameter('ezdesign.themes_list'); - $container->setParameter('ezdesign.themes_list', array_unique( - array_merge($themesList, array_keys($themesPathMap))) + $themesList = $container->getParameter('ibexa.design.themes.list'); + $container->setParameter( + 'ibexa.design.themes.list', + array_unique( + array_merge($themesList, array_keys($themesPathMap)) + ) ); - $container->setParameter('ezdesign.templates_path_map', $themesPathMap); + $container->setParameter('ibexa.design.templates.path_map', $themesPathMap); $twigDataCollector = $container->findDefinition('data_collector.twig'); $twigDataCollector->setClass(TwigDataCollector::class); @@ -99,11 +104,13 @@ public function process(ContainerBuilder $container) if (\count($twigDataCollector->getArguments()) === 1) { // In versions of Symfony prior to 3.4, "data_collector.twig" had only one // argument, we're adding "twig" service to satisfy constructor overriden - // in EzSystems\EzPlatformDesignEngineBundle\DataCollector\TwigDataCollector + // in \IbexaDesignEngineBundle\DataCollector\TwigDataCollector // which is based on Symfony 3.4 version of base TwigDataCollector $twigDataCollector->addArgument(new Reference('twig')); } - $twigDataCollector->addArgument(new Reference('ezdesign.template_path_registry')); + $twigDataCollector->addArgument(new Reference(TemplatePathRegistry::class)); } } + +class_alias(TwigThemePass::class, 'EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler\TwigThemePass'); diff --git a/bundle/DependencyInjection/Configuration.php b/src/bundle/DependencyInjection/Configuration.php similarity index 63% rename from bundle/DependencyInjection/Configuration.php rename to src/bundle/DependencyInjection/Configuration.php index 23aa72b..be9fbc3 100644 --- a/bundle/DependencyInjection/Configuration.php +++ b/src/bundle/DependencyInjection/Configuration.php @@ -4,16 +4,16 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle\DependencyInjection; +namespace Ibexa\Bundle\DesignEngine\DependencyInjection; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\Configuration as SiteAccessConfiguration; use Symfony\Component\Config\Definition\Builder\TreeBuilder; class Configuration extends SiteAccessConfiguration { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder('ezdesign'); + $treeBuilder = new TreeBuilder(IbexaDesignEngineExtension::EXTENSION_NAME); $rootNode = $treeBuilder->getRootNode(); $rootNode @@ -43,22 +43,10 @@ public function getConfigTreeBuilder() ->info('If set to true, assets path won\'t be pre-resolved at compile time.') ->defaultValue('%kernel.debug%') ->end() - ->arrayNode('phpstorm') - ->addDefaultsIfNotSet() - ->setDeprecated('The "%node%" option is deprecated since Ibexa DXP v3.3.14 and will be removed in 4.0. Use PhpStorm plugin instead: https://doc.ibexa.co/en/latest/community_resources/phpstorm_plugin/') - ->children() - ->booleanNode('enabled') - ->defaultValue(false) - ->info('Activates PHPStorm support') - ->end() - ->scalarNode('twig_config_path') - ->info('Path where to store PHPStorm configuration file for additional Twig namespaces (ide-twig.json).') - ->defaultValue('%kernel.project_dir%') - ->end() - ->end() - ->end() ->end(); return $treeBuilder; } } + +class_alias(Configuration::class, 'EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Configuration'); diff --git a/bundle/DependencyInjection/DesignConfigParser.php b/src/bundle/DependencyInjection/DesignConfigParser.php similarity index 73% rename from bundle/DependencyInjection/DesignConfigParser.php rename to src/bundle/DependencyInjection/DesignConfigParser.php index e5e702f..c31a7d0 100644 --- a/bundle/DependencyInjection/DesignConfigParser.php +++ b/src/bundle/DependencyInjection/DesignConfigParser.php @@ -4,10 +4,10 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle\DependencyInjection; +namespace Ibexa\Bundle\DesignEngine\DependencyInjection; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ParserInterface; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\ParserInterface; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; use Symfony\Component\Config\Definition\Builder\NodeBuilder; class DesignConfigParser implements ParserInterface @@ -32,7 +32,9 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder) $nodeBuilder ->scalarNode('design') ->cannotBeEmpty() - ->info('Name of the design to use. Must be declared in ezdesign.design_list') + ->info('Name of the design to use. Must be declared in "ibexa.design.list"') ->end(); } } + +class_alias(DesignConfigParser::class, 'EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\DesignConfigParser'); diff --git a/bundle/DependencyInjection/EzPlatformDesignEngineExtension.php b/src/bundle/DependencyInjection/IbexaDesignEngineExtension.php similarity index 61% rename from bundle/DependencyInjection/EzPlatformDesignEngineExtension.php rename to src/bundle/DependencyInjection/IbexaDesignEngineExtension.php index e67f22c..43b5549 100644 --- a/bundle/DependencyInjection/EzPlatformDesignEngineExtension.php +++ b/src/bundle/DependencyInjection/IbexaDesignEngineExtension.php @@ -4,19 +4,21 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle\DependencyInjection; +namespace Ibexa\Bundle\DesignEngine\DependencyInjection; -use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; +use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -class EzPlatformDesignEngineExtension extends Extension +class IbexaDesignEngineExtension extends Extension { + public const EXTENSION_NAME = 'ibexa_design_engine'; + public function getAlias() { - return 'ezdesign'; + return self::EXTENSION_NAME; } public function getConfiguration(array $config, ContainerBuilder $container) @@ -41,13 +43,11 @@ private function configureDesigns(array $config, ConfigurationProcessor $process { // Always add "standard" design to the list (defaults to application level & override paths only) $config['design_list'] += ['standard' => []]; - $container->setParameter('ezdesign.design_list', $config['design_list']); - $container->setParameter('ezdesign.templates_override_paths', $config['templates_override_paths']); - $container->setParameter('ezdesign.templates_path_map', $config['templates_theme_paths']); - $container->setParameter('ezdesign.asset_resolution.disabled', $config['disable_assets_pre_resolution']); - - // PHPStorm settings - $container->setParameter('ezdesign.phpstorm.enabled', $config['phpstorm']['enabled']); - $container->setParameter('ezdesign.phpstorm.twig_config_path', $config['phpstorm']['twig_config_path']); + $container->setParameter('ibexa.design.list', $config['design_list']); + $container->setParameter('ibexa.design.templates.override_paths', $config['templates_override_paths']); + $container->setParameter('ibexa.design.templates.path_map', $config['templates_theme_paths']); + $container->setParameter('ibexa.design.assets.resolution.disabled', $config['disable_assets_pre_resolution']); } } + +class_alias(IbexaDesignEngineExtension::class, 'EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\EzPlatformDesignEngineExtension'); diff --git a/bundle/EzPlatformDesignEngineBundle.php b/src/bundle/IbexaDesignEngineBundle.php similarity index 55% rename from bundle/EzPlatformDesignEngineBundle.php rename to src/bundle/IbexaDesignEngineBundle.php index 3f7ac80..dde81f2 100644 --- a/bundle/EzPlatformDesignEngineBundle.php +++ b/src/bundle/IbexaDesignEngineBundle.php @@ -4,25 +4,25 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngineBundle; +namespace Ibexa\Bundle\DesignEngine; -use EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler\AssetPathResolutionPass; -use EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler\AssetThemePass; -use EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\Compiler\TwigThemePass; -use EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\DesignConfigParser; -use EzSystems\EzPlatformDesignEngineBundle\DependencyInjection\EzPlatformDesignEngineExtension; +use Ibexa\Bundle\DesignEngine\DependencyInjection\Compiler\AssetPathResolutionPass; +use Ibexa\Bundle\DesignEngine\DependencyInjection\Compiler\AssetThemePass; +use Ibexa\Bundle\DesignEngine\DependencyInjection\Compiler\TwigThemePass; +use Ibexa\Bundle\DesignEngine\DependencyInjection\DesignConfigParser; +use Ibexa\Bundle\DesignEngine\DependencyInjection\IbexaDesignEngineExtension; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; -class EzPlatformDesignEngineBundle extends Bundle +class IbexaDesignEngineBundle extends Bundle { public function build(ContainerBuilder $container) { parent::build($container); - /** @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension $eZExtension */ - $eZExtension = $container->getExtension('ezpublish'); + /** @var \Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension $eZExtension */ + $eZExtension = $container->getExtension('ibexa'); $eZExtension->addConfigParser(new DesignConfigParser()); $eZExtension->addDefaultSettings(__DIR__ . '/Resources/config', ['default_settings.yaml']); @@ -34,9 +34,11 @@ public function build(ContainerBuilder $container) public function getContainerExtension() { if (!isset($this->extension)) { - $this->extension = new EzPlatformDesignEngineExtension(); + $this->extension = new IbexaDesignEngineExtension(); } return $this->extension; } } + +class_alias(IbexaDesignEngineBundle::class, 'EzSystems\EzPlatformDesignEngineBundle\EzPlatformDesignEngineBundle'); diff --git a/src/bundle/Resources/config/default_settings.yaml b/src/bundle/Resources/config/default_settings.yaml new file mode 100644 index 0000000..63859b4 --- /dev/null +++ b/src/bundle/Resources/config/default_settings.yaml @@ -0,0 +1,2 @@ +parameters: + ibexa.site_access.config.default.design: standard diff --git a/src/bundle/Resources/config/services.yaml b/src/bundle/Resources/config/services.yaml new file mode 100644 index 0000000..9ca15ed --- /dev/null +++ b/src/bundle/Resources/config/services.yaml @@ -0,0 +1,53 @@ +parameters: + ibexa.design.themes.list: [] + ibexa.design.list: [] + ibexa.design.templates.path_map: {} + ibexa.design.assets.path_map: {} + ibexa.design.templates.override_paths: [] + ibexa.design.assets.override_paths: [] + ibexa.design.assets.resolved_paths: {} + ibexa.design.assets.resolution.disabled: '%kernel.debug%' + +services: + Ibexa\DesignEngine\Templating\ThemeTemplateNameResolver: + class: Ibexa\DesignEngine\Templating\ThemeTemplateNameResolver + arguments: ['@ibexa.config.resolver'] + + Ibexa\DesignEngine\Templating\TemplatePathRegistry: + class: Ibexa\DesignEngine\Templating\TemplatePathRegistry + arguments: ["%kernel.project_dir%"] + + Ibexa\DesignEngine\Templating\Twig\TwigThemeLoader: + class: Ibexa\DesignEngine\Templating\Twig\TwigThemeLoader + public: false + decorates: twig.loader.native_filesystem + arguments: + - '@Ibexa\DesignEngine\Templating\ThemeTemplateNameResolver' + - '@Ibexa\DesignEngine\Templating\TemplatePathRegistry' + - '@Ibexa\DesignEngine\Templating\Twig\TwigThemeLoader.inner' + + Ibexa\DesignEngine\Asset\AssetPathResolver: + class: Ibexa\DesignEngine\Asset\AssetPathResolver + arguments: + - '%ibexa.design.assets.path_map%' + - "%webroot_dir%" + public: false + + Ibexa\DesignEngine\Asset\ProvisionedPathResolver: + class: Ibexa\DesignEngine\Asset\ProvisionedPathResolver + arguments: + - '%ibexa.design.assets.resolved_paths%' + - '@Ibexa\DesignEngine\Asset\AssetPathResolver' + - '%webroot_dir%' + public: false + + ibexadesign.asset_path_resolver: + alias: Ibexa\DesignEngine\Asset\AssetPathResolver + + Ibexa\DesignEngine\Asset\ThemePackage: + class: Ibexa\DesignEngine\Asset\ThemePackage + arguments: + - '@ibexadesign.asset_path_resolver' + - "@assets._default_package" + calls: + - [setConfigResolver, ['@ibexa.config.resolver']] diff --git a/src/contracts/DesignAwareInterface.php b/src/contracts/DesignAwareInterface.php new file mode 100644 index 0000000..047c147 --- /dev/null +++ b/src/contracts/DesignAwareInterface.php @@ -0,0 +1,16 @@ +innerPackage->getVersion($this->pathResolver->resolveAssetPath($path, $this->getCurrentDesign())); } } + +class_alias(ThemePackage::class, 'EzSystems\EzPlatformDesignEngine\Asset\ThemePackage'); diff --git a/lib/DesignAwareTrait.php b/src/lib/DesignAwareTrait.php similarity index 58% rename from lib/DesignAwareTrait.php rename to src/lib/DesignAwareTrait.php index 8848411..ae5f351 100644 --- a/lib/DesignAwareTrait.php +++ b/src/lib/DesignAwareTrait.php @@ -4,29 +4,26 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine; +namespace Ibexa\DesignEngine; -use eZ\Publish\Core\MVC\ConfigResolverInterface; +use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; trait DesignAwareTrait { /** - * @var \eZ\Publish\Core\MVC\ConfigResolverInterface + * @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ private $configResolver; - public function setConfigResolver(ConfigResolverInterface $configResolver) + public function setConfigResolver(ConfigResolverInterface $configResolver): void { $this->configResolver = $configResolver; } - /** - * Returns the current design. - * - * @return string - */ - public function getCurrentDesign() + public function getCurrentDesign(): ?string { return $this->configResolver->getParameter('design'); } } + +class_alias(DesignAwareTrait::class, 'EzSystems\EzPlatformDesignEngine\DesignAwareTrait'); diff --git a/lib/Exception/InvalidDesignException.php b/src/lib/Exception/InvalidDesignException.php similarity index 64% rename from lib/Exception/InvalidDesignException.php rename to src/lib/Exception/InvalidDesignException.php index d31973c..3d63936 100644 --- a/lib/Exception/InvalidDesignException.php +++ b/src/lib/Exception/InvalidDesignException.php @@ -4,10 +4,12 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Exception; +namespace Ibexa\DesignEngine\Exception; use InvalidArgumentException; class InvalidDesignException extends InvalidArgumentException { } + +class_alias(InvalidDesignException::class, 'EzSystems\EzPlatformDesignEngine\Exception\InvalidDesignException'); diff --git a/lib/Templating/TemplateNameResolverInterface.php b/src/lib/Templating/TemplateNameResolverInterface.php similarity index 56% rename from lib/Templating/TemplateNameResolverInterface.php rename to src/lib/Templating/TemplateNameResolverInterface.php index 61142d8..55c773f 100644 --- a/lib/Templating/TemplateNameResolverInterface.php +++ b/src/lib/Templating/TemplateNameResolverInterface.php @@ -4,15 +4,21 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Templating; +namespace Ibexa\DesignEngine\Templating; + +use Ibexa\Contracts\DesignEngine\DesignAwareInterface; /** * Interface for template name resolvers. * A template name resolver will check provided template name and resolve it for current design. */ -interface TemplateNameResolverInterface +interface TemplateNameResolverInterface extends DesignAwareInterface { - const EZ_DESIGN_NAMESPACE = 'ezdesign'; + /** + * @deprecated since Ibexa 4.0. Use + * {@see \Ibexa\Contracts\DesignEngine\DesignAwareInterface::DESIGN_NAMESPACE} instead. + */ + public const EZ_DESIGN_NAMESPACE = 'ezdesign'; /** * Resolves provided template name within current design and returns properly namespaced template name. @@ -24,7 +30,7 @@ interface TemplateNameResolverInterface public function resolveTemplateName($name); /** - * Checks if provided template name is using @ezdesign namespace. + * Checks if provided template name is using @ibexadesign namespace. * * @param string $name * @@ -32,3 +38,5 @@ public function resolveTemplateName($name); */ public function isTemplateDesignNamespaced($name); } + +class_alias(TemplateNameResolverInterface::class, 'EzSystems\EzPlatformDesignEngine\Templating\TemplateNameResolverInterface'); diff --git a/lib/Templating/TemplatePathRegistry.php b/src/lib/Templating/TemplatePathRegistry.php similarity index 88% rename from lib/Templating/TemplatePathRegistry.php rename to src/lib/Templating/TemplatePathRegistry.php index 32c01be..c5f5ff8 100644 --- a/lib/Templating/TemplatePathRegistry.php +++ b/src/lib/Templating/TemplatePathRegistry.php @@ -4,7 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Templating; +namespace Ibexa\DesignEngine\Templating; use Serializable; @@ -47,3 +47,5 @@ public function unserialize($serialized) list($this->pathMap, $this->kernelRootDir) = unserialize($serialized); } } + +class_alias(TemplatePathRegistry::class, 'EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistry'); diff --git a/lib/Templating/TemplatePathRegistryInterface.php b/src/lib/Templating/TemplatePathRegistryInterface.php similarity index 83% rename from lib/Templating/TemplatePathRegistryInterface.php rename to src/lib/Templating/TemplatePathRegistryInterface.php index d410384..b14326e 100644 --- a/lib/Templating/TemplatePathRegistryInterface.php +++ b/src/lib/Templating/TemplatePathRegistryInterface.php @@ -4,7 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Templating; +namespace Ibexa\DesignEngine\Templating; /** * Registry to map templates logical names and their real path. @@ -36,3 +36,5 @@ public function getTemplatePath($templateName); */ public function getPathMap(); } + +class_alias(TemplatePathRegistryInterface::class, 'EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistryInterface'); diff --git a/src/lib/Templating/ThemeTemplateNameResolver.php b/src/lib/Templating/ThemeTemplateNameResolver.php new file mode 100644 index 0000000..2d99078 --- /dev/null +++ b/src/lib/Templating/ThemeTemplateNameResolver.php @@ -0,0 +1,47 @@ +setConfigResolver($configResolver); + } + + public function resolveTemplateName($name) + { + if (!$this->isTemplateDesignNamespaced($name)) { + return $name; + } + + return $this->resolvedTemplateNames[$name] ?? ($this->resolvedTemplateNames[$name] = str_replace( + '@' . static::DESIGN_NAMESPACE, + '@' . $this->getCurrentDesign(), + $name + )); + } + + public function isTemplateDesignNamespaced($name) + { + return (strpos($name, '@' . static::DESIGN_NAMESPACE) !== false) || (strpos($name, '@' . $this->getCurrentDesign()) !== false); + } +} + +class_alias(ThemeTemplateNameResolver::class, 'EzSystems\EzPlatformDesignEngine\Templating\ThemeTemplateNameResolver'); diff --git a/lib/Templating/Twig/TwigThemeLoader.php b/src/lib/Templating/Twig/TwigThemeLoader.php similarity index 84% rename from lib/Templating/Twig/TwigThemeLoader.php rename to src/lib/Templating/Twig/TwigThemeLoader.php index 64c923e..7c919b0 100644 --- a/lib/Templating/Twig/TwigThemeLoader.php +++ b/src/lib/Templating/Twig/TwigThemeLoader.php @@ -4,27 +4,27 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Templating\Twig; +namespace Ibexa\DesignEngine\Templating\Twig; -use EzSystems\EzPlatformDesignEngine\Templating\TemplateNameResolverInterface; -use EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistryInterface; +use Ibexa\DesignEngine\Templating\TemplateNameResolverInterface; +use Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface; use Twig\Loader\FilesystemLoader; use Twig\Loader\LoaderInterface; use Twig\Source; /** * Decorates regular Twig FilesystemLoader. - * It resolves generic @ezdesign namespace to the actual current namespace. + * It resolves generic @ibexadesign namespace to the actual current namespace. */ class TwigThemeLoader implements LoaderInterface { /** - * @var \EzSystems\EzPlatformDesignEngine\Templating\TemplateNameResolverInterface + * @var \Ibexa\DesignEngine\Templating\TemplateNameResolverInterface */ private $nameResolver; /** - * @var \EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistryInterface + * @var \Ibexa\DesignEngine\Templating\TemplatePathRegistryInterface */ private $pathRegistry; @@ -96,3 +96,5 @@ public function prependPath($path, $namespace = FilesystemLoader::MAIN_NAMESPACE $this->innerFilesystemLoader->prependPath($path, $namespace); } } + +class_alias(TwigThemeLoader::class, 'EzSystems\EzPlatformDesignEngine\Templating\Twig\TwigThemeLoader'); diff --git a/tests/lib/Asset/AssetPathResolverTest.php b/tests/lib/Asset/AssetPathResolverTest.php index faa6c61..6582bc5 100644 --- a/tests/lib/Asset/AssetPathResolverTest.php +++ b/tests/lib/Asset/AssetPathResolverTest.php @@ -4,10 +4,10 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Tests\Asset; +namespace Ibexa\Tests\DesignEngine\Asset; -use EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolver; -use EzSystems\EzPlatformDesignEngine\Exception\InvalidDesignException; +use Ibexa\DesignEngine\Asset\AssetPathResolver; +use Ibexa\DesignEngine\Exception\InvalidDesignException; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -27,7 +27,7 @@ public function testResolveAssetPathFail() } /** - * @covers \EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolver::resolveAssetPath + * @covers \Ibexa\DesignEngine\Asset\AssetPathResolver::resolveAssetPath */ public function testResolveInvalidDesign() { @@ -131,3 +131,5 @@ public function testResolveAssetPath(array $designPaths, array $existingPaths, $ self::assertSame($resolvedPath, $resolver->resolveAssetPath($path, 'foo')); } } + +class_alias(AssetPathResolverTest::class, 'EzSystems\EzPlatformDesignEngine\Tests\Asset\AssetPathResolverTest'); diff --git a/tests/lib/Asset/ProvisionedPathResolverTest.php b/tests/lib/Asset/ProvisionedPathResolverTest.php index f7c8160..1a60dd6 100644 --- a/tests/lib/Asset/ProvisionedPathResolverTest.php +++ b/tests/lib/Asset/ProvisionedPathResolverTest.php @@ -4,18 +4,18 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Tests\Asset; +namespace Ibexa\Tests\DesignEngine\Asset; -use EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolver; -use EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolverInterface; -use EzSystems\EzPlatformDesignEngine\Asset\ProvisionedPathResolver; +use Ibexa\DesignEngine\Asset\AssetPathResolver; +use Ibexa\DesignEngine\Asset\AssetPathResolverInterface; +use Ibexa\DesignEngine\Asset\ProvisionedPathResolver; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; class ProvisionedPathResolverTest extends TestCase { /** - * @var \PHPUnit\Framework\MockObject\MockObject|\EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolverInterface + * @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\DesignEngine\Asset\AssetPathResolverInterface */ private $innerResolver; @@ -111,3 +111,5 @@ public function testProvisionResolvedPaths() self::assertEquals($expectedResolvedPaths, $provisioner->provisionResolvedPaths($themesPaths, $design)); } } + +class_alias(ProvisionedPathResolverTest::class, 'EzSystems\EzPlatformDesignEngine\Tests\Asset\ProvisionedPathResolverTest'); diff --git a/tests/lib/Asset/ThemePackageTest.php b/tests/lib/Asset/ThemePackageTest.php index a83dc79..ecdddfc 100644 --- a/tests/lib/Asset/ThemePackageTest.php +++ b/tests/lib/Asset/ThemePackageTest.php @@ -4,18 +4,18 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Tests\Asset; +namespace Ibexa\Tests\DesignEngine\Asset; -use eZ\Publish\Core\MVC\ConfigResolverInterface; -use EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolverInterface; -use EzSystems\EzPlatformDesignEngine\Asset\ThemePackage; +use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; +use Ibexa\DesignEngine\Asset\AssetPathResolverInterface; +use Ibexa\DesignEngine\Asset\ThemePackage; use PHPUnit\Framework\TestCase; use Symfony\Component\Asset\PackageInterface; class ThemePackageTest extends TestCase { /** - * @var \PHPUnit\Framework\MockObject\MockObject|\EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolverInterface + * @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\DesignEngine\Asset\AssetPathResolverInterface */ private $assetPathResolver; @@ -25,7 +25,7 @@ class ThemePackageTest extends TestCase private $innerPackage; /** - * @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\Core\MVC\ConfigResolverInterface + * @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ private $configResolver; @@ -91,3 +91,5 @@ public function testGetVersion() self::assertSame($version, $package->getVersion($assetPath)); } } + +class_alias(ThemePackageTest::class, 'EzSystems\EzPlatformDesignEngine\Tests\Asset\ThemePackageTest'); diff --git a/tests/lib/Templating/TemplatePathRegistryTest.php b/tests/lib/Templating/TemplatePathRegistryTest.php index 8e3f77f..c77f23c 100644 --- a/tests/lib/Templating/TemplatePathRegistryTest.php +++ b/tests/lib/Templating/TemplatePathRegistryTest.php @@ -4,9 +4,9 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Tests\Templating; +namespace Ibexa\Tests\DesignEngine\Templating; -use EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistry; +use Ibexa\DesignEngine\Templating\TemplatePathRegistry; use PHPUnit\Framework\TestCase; class TemplatePathRegistryTest extends TestCase @@ -54,3 +54,5 @@ public function testGetTemplatePathNotMapped() self::assertSame($templateLogicalName, $registry->getTemplatePath($templateLogicalName)); } } + +class_alias(TemplatePathRegistryTest::class, 'EzSystems\EzPlatformDesignEngine\Tests\Templating\TemplatePathRegistryTest'); diff --git a/tests/lib/Templating/ThemeTemplateNameResolverTest.php b/tests/lib/Templating/ThemeTemplateNameResolverTest.php index c21652a..f8d66b2 100644 --- a/tests/lib/Templating/ThemeTemplateNameResolverTest.php +++ b/tests/lib/Templating/ThemeTemplateNameResolverTest.php @@ -4,16 +4,16 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ -namespace EzSystems\EzPlatformDesignEngine\Tests\Templating; +namespace Ibexa\Tests\DesignEngine\Templating; -use eZ\Publish\Core\MVC\ConfigResolverInterface; -use EzSystems\EzPlatformDesignEngine\Templating\ThemeTemplateNameResolver; +use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; +use Ibexa\DesignEngine\Templating\ThemeTemplateNameResolver; use PHPUnit\Framework\TestCase; class ThemeTemplateNameResolverTest extends TestCase { /** - * @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\Core\MVC\ConfigResolverInterface + * @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */ private $configResolver; @@ -28,7 +28,7 @@ public function templateNameProvider() { return [ [null, 'foo.html.twig', 'foo.html.twig'], - ['my_design', '@ezdesign/foo.html.twig', '@my_design/foo.html.twig'], + ['my_design', '@ibexadesign/foo.html.twig', '@my_design/foo.html.twig'], ['my_design', '@AcmeTest/foo.html.twig', '@AcmeTest/foo.html.twig'], ]; } @@ -50,7 +50,7 @@ public function isTemplateDesignNamespacedProvider() { return [ [null, 'foo.html.twig', false], - ['my_design', '@ezdesign/foo.html.twig', true], + ['my_design', '@ibexadesign/foo.html.twig', true], ['my_design', '@my_design/foo.html.twig', true], ['my_design', '@AcmeTest/foo.html.twig', false], ]; @@ -69,3 +69,5 @@ public function testIsTemplateDesignNamespaced($currentDesign, $templateName, $e self::assertSame($expected, $resolver->isTemplateDesignNamespaced($templateName)); } } + +class_alias(ThemeTemplateNameResolverTest::class, 'EzSystems\EzPlatformDesignEngine\Tests\Templating\ThemeTemplateNameResolverTest');