From bc9fb0546c9973e0d4a6fb413f90071a8f0b3f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sat, 22 Mar 2025 14:41:50 +0100 Subject: [PATCH 1/9] Sylius 2.x dependency upgrade --- composer.json | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index e0982aa..73d9f12 100644 --- a/composer.json +++ b/composer.json @@ -10,34 +10,34 @@ "sylius-plugin" ], "require": { - "php": ">=7.4", - "doctrine/collections": "^1.6", + "php": ">=8.2", + "doctrine/collections": "^2.2", "doctrine/orm": "^2.7", "doctrine/persistence": "^1.3 || ^2.1 || ^3.0", "league/uri": "^6.0 || ^7.5", "league/uri-components": "^2.3 || ^7.5", "psr/log": "^1.1 || ^2.0 || ^3.0", - "sylius/channel": "^1.0", - "sylius/channel-bundle": "^1.0", - "sylius/core-bundle": "^1.0", - "sylius/product-bundle": "^1.0", - "sylius/resource-bundle": "^1.6", - "sylius/taxonomy-bundle": "^1.0", - "sylius/ui-bundle": "^1.0", - "symfony/config": "^5.4 || ^6.0", - "symfony/console": "^5.4 || ^6.0", - "symfony/dependency-injection": "^5.4 || ^6.0", - "symfony/event-dispatcher": "^5.4 || ^6.0", - "symfony/form": "^5.4 || ^6.0", - "symfony/http-foundation": "^5.4 || ^6.0", - "symfony/http-kernel": "^5.4 || ^6.0", - "symfony/routing": "^5.4 || ^6.0", - "symfony/validator": "^5.4 || ^6.0", + "sylius/channel": "^2.0", + "sylius/channel-bundle": "^2.0", + "sylius/core-bundle": "^2.0", + "sylius/product-bundle": "^2.0", + "sylius/resource-bundle": "^1.12", + "sylius/taxonomy-bundle": "^2.0", + "sylius/ui-bundle": "^2.0", + "symfony/config": "^6.4 || ^7.1", + "symfony/console": "^6.4 || ^7.1", + "symfony/dependency-injection": "^6.4 || ^7.1", + "symfony/event-dispatcher": "^6.4 || ^7.1", + "symfony/form": "^6.4 || ^7.1", + "symfony/http-foundation": "^6.4 || ^7.1", + "symfony/http-kernel": "^6.4 || ^7.1", + "symfony/routing": "^6.4 || ^7.1", + "symfony/validator": "^6.4 || ^7.1", "webmozart/assert": "^1.11" }, "require-dev": { "api-platform/core": "^2.7", - "lexik/jwt-authentication-bundle": "^2.16", + "lexik/jwt-authentication-bundle": "^3.1", "php-http/message-factory": "^1.1", "phpspec/phpspec": "^7.3", "phpspec/prophecy-phpunit": "^2.0", @@ -47,12 +47,12 @@ "setono/code-quality-pack": "^2.9", "setono/sylius-behat-pack": "^0.2", "shipmonk/composer-dependency-analyser": "^1.8", - "sylius/sylius": "~1.10.14", - "symfony/debug-bundle": "^5.4 || ^6.0", - "symfony/dotenv": "^5.4 || ^6.0", - "symfony/intl": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "symfony/webpack-encore-bundle": "^1.16" + "sylius/sylius": "~2.0.0", + "symfony/debug-bundle": "^6.4 || ^7.1", + "symfony/dotenv": "^6.4 || ^7.1", + "symfony/intl": "^6.4 || ^7.1", + "symfony/web-profiler-bundle": "^6.4 || ^7.1", + "symfony/webpack-encore-bundle": "^2.2" }, "prefer-stable": true, "autoload": { @@ -73,6 +73,7 @@ "dealerdirect/phpcodesniffer-composer-installer": false, "ergebnis/composer-normalize": true, "ocramius/package-versions": true, + "php-http/discovery": true, "symfony/thanks": false }, "sort-packages": true From 79c44b510143f49122c0863ddaf794ce9a510f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sat, 22 Mar 2025 14:51:59 +0100 Subject: [PATCH 2/9] Fix "command cannot have an empty name" error --- src/Command/RemoveRedirectsCommand.php | 6 +++-- .../public/admin/js/updateProductSlug.js | 26 ------------------ src/Resources/public/admin/js/updateSlug.js | 17 ------------ .../public/admin/js/updateTaxonSlug.js | 27 ------------------- .../Admin/Product/_javascripts.html.twig | 1 - .../views/Admin/Taxon/_javascripts.html.twig | 1 - .../views/Admin/_javascripts.html.twig | 1 - .../Product/_slugField.html.twig | 18 ------------- .../Taxon/_slugField.html.twig | 18 ------------- 9 files changed, 4 insertions(+), 111 deletions(-) delete mode 100644 src/Resources/public/admin/js/updateProductSlug.js delete mode 100644 src/Resources/public/admin/js/updateSlug.js delete mode 100644 src/Resources/public/admin/js/updateTaxonSlug.js delete mode 100644 src/Resources/views/Admin/Product/_javascripts.html.twig delete mode 100644 src/Resources/views/Admin/Taxon/_javascripts.html.twig delete mode 100644 src/Resources/views/Admin/_javascripts.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Product/_slugField.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Taxon/_slugField.html.twig diff --git a/src/Command/RemoveRedirectsCommand.php b/src/Command/RemoveRedirectsCommand.php index c101cc1..07def0e 100644 --- a/src/Command/RemoveRedirectsCommand.php +++ b/src/Command/RemoveRedirectsCommand.php @@ -11,9 +11,9 @@ class RemoveRedirectsCommand extends Command { - protected static $defaultName = 'setono:sylius-redirect:remove'; + protected static string $defaultName = 'setono:sylius-redirect:remove'; - protected static $defaultDescription = 'This command will remove redirects that have not been accessed later than x days ago where x is the `setono_sylius_redirect.remove_after` parameter'; + protected static string $defaultDescription = 'This command will remove redirects that have not been accessed later than x days ago where x is the `setono_sylius_redirect.remove_after` parameter'; private RedirectRepositoryInterface $redirectRepository; @@ -25,6 +25,8 @@ class RemoveRedirectsCommand extends Command public function __construct(RedirectRepositoryInterface $redirectRepository, int $removeAfter) { parent::__construct(); + $this->setName(self::$defaultName); + $this->setDescription(self::$defaultDescription); $this->redirectRepository = $redirectRepository; $this->removeAfter = $removeAfter; diff --git a/src/Resources/public/admin/js/updateProductSlug.js b/src/Resources/public/admin/js/updateProductSlug.js deleted file mode 100644 index 8acbca3..0000000 --- a/src/Resources/public/admin/js/updateProductSlug.js +++ /dev/null @@ -1,26 +0,0 @@ -$(function () { - let $body = $('body'); - - hideAutomaticRedirectionInput(); - $body.on('click', '.toggle-product-slug-modification', function () { - let $input = $(this).parent().find('input'); - - handleAutomaticRedirectionInput($input); - }); - $('.toggle-product-slug-modification').each(function () { - let $input = $(this).parent().find('input'); - $input.on('keyup', function () { - handleAutomaticRedirectionInput($(this)); - }); - }); - - $(document).ajaxComplete(function (event, request, settings) { - if (settings.url.indexOf('ajax/products/generate-slug') !== -1) { - $('.toggle-product-slug-modification').each(function () { - let $input = $(this).parent().find('input'); - - $input.trigger('keyup'); - }); - } - }); -}); diff --git a/src/Resources/public/admin/js/updateSlug.js b/src/Resources/public/admin/js/updateSlug.js deleted file mode 100644 index 5038df4..0000000 --- a/src/Resources/public/admin/js/updateSlug.js +++ /dev/null @@ -1,17 +0,0 @@ -function handleAutomaticRedirectionInput($input) { - let slugHasChanged = $input.attr('value') !== $input.val(); - - if (slugHasChanged) { - showAutomaticRedirectionInput(); - } else { - hideAutomaticRedirectionInput(); - } -} - -function hideAutomaticRedirectionInput() { - $('.js-add-automatic-redirection-checkbox').parent().css({'display': 'none'}); -} - -function showAutomaticRedirectionInput() { - $('.js-add-automatic-redirection-checkbox').parent().css({'display': 'initial'}); -} diff --git a/src/Resources/public/admin/js/updateTaxonSlug.js b/src/Resources/public/admin/js/updateTaxonSlug.js deleted file mode 100644 index 77f6df5..0000000 --- a/src/Resources/public/admin/js/updateTaxonSlug.js +++ /dev/null @@ -1,27 +0,0 @@ -$(function () { - let $body = $('body'); - - hideAutomaticRedirectionInput(); - $body.on('click', '.toggle-taxon-slug-modification', function () { - let $input = $(this).parent().find('input'); - - handleAutomaticRedirectionInput($input); - }); - $('.toggle-taxon-slug-modification').each(function () { - let $input = $(this).parent().find('input'); - $input.on('keyup', function () { - handleAutomaticRedirectionInput($(this)); - }); - }); - - $(document).ajaxComplete(function (event, request, settings) { - if (settings.url.indexOf('ajax/taxons/generate-slug') !== -1) { - $('.toggle-taxon-slug-modification').each(function () { - let $input = $(this).parent().find('input'); - - $input.trigger('keyup'); - }); - } - }); -}); - diff --git a/src/Resources/views/Admin/Product/_javascripts.html.twig b/src/Resources/views/Admin/Product/_javascripts.html.twig deleted file mode 100644 index 8c7a6b9..0000000 --- a/src/Resources/views/Admin/Product/_javascripts.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/setonosyliusredirectplugin/admin/js/updateProductSlug.js'} %} diff --git a/src/Resources/views/Admin/Taxon/_javascripts.html.twig b/src/Resources/views/Admin/Taxon/_javascripts.html.twig deleted file mode 100644 index b856148..0000000 --- a/src/Resources/views/Admin/Taxon/_javascripts.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/setonosyliusredirectplugin/admin/js/updateTaxonSlug.js'} %} diff --git a/src/Resources/views/Admin/_javascripts.html.twig b/src/Resources/views/Admin/_javascripts.html.twig deleted file mode 100644 index 7a76e01..0000000 --- a/src/Resources/views/Admin/_javascripts.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/setonosyliusredirectplugin/admin/js/updateSlug.js'} %} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Product/_slugField.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Product/_slugField.html.twig deleted file mode 100644 index c2ac4c2..0000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Product/_slugField.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -
- {{ form_label(slugField) }} - {% if slugField.vars.value == null %} - {{ form_widget(slugField, {'attr': {'data-url': path('sylius_admin_ajax_generate_product_slug')}}) }} - {% else %} -
- {{ form_widget(slugField, {'attr': {'readonly': 'readonly', 'data-url': path('sylius_admin_ajax_generate_product_slug')}}) }} - - - -
- {% endif %} - {{ form_errors(slugField) }} -
- -{% if slugField.parent is defined and slugField.parent.addAutomaticRedirect is defined %} - {{ form_row(slugField.parent.addAutomaticRedirect) }} -{% endif %} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Taxon/_slugField.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Taxon/_slugField.html.twig deleted file mode 100644 index 3147a4d..0000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Taxon/_slugField.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -
- {{ form_label(slugField) }} - {% if resource.slug == null %} - {{ form_widget(slugField, {'attr': {'data-url': path('sylius_admin_ajax_generate_taxon_slug'), 'data-parent': app.request.attributes.get('id')}}) }} - {% else %} -
- {{ form_widget(slugField, {'attr': {'readonly': 'readonly', 'data-url': path('sylius_admin_ajax_generate_taxon_slug')}}) }} - - - -
- {% endif %} - {{ form_errors(slugField) }} -
- -{% if slugField.parent is defined and slugField.parent.addAutomaticRedirect is defined %} - {{ form_row(slugField.parent.addAutomaticRedirect) }} -{% endif %} From 2cd36f573a66b08e6b7bd65bcce73a3ec66db2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sat, 22 Mar 2025 19:36:22 +0100 Subject: [PATCH 3/9] Sylius 2.0 compatibility --- README.md | 6 +- ecs.php | 21 ++++--- psalm-baseline.xml | 3 + src/EventListener/ControllerSubscriber.php | 4 +- src/EventListener/NotFoundSubscriber.php | 4 +- src/EventListener/RedirectResponseTrait.php | 2 +- src/Factory/RedirectFactory.php | 2 +- src/Factory/RedirectFactoryInterface.php | 2 +- src/Model/Redirect.php | 1 - src/Repository/RedirectRepository.php | 2 +- src/Resolver/RedirectionPathResolver.php | 6 +- .../RedirectionPathResolverInterface.php | 2 +- src/Resources/config/admin_routing.yaml | 2 +- src/Resources/config/app/config.yaml | 1 + ...setono_sylius_redirect_admin_redirect.yaml | 4 +- src/Resources/config/services.xml | 1 + src/Resources/config/services/twig.xml | 16 ++++++ src/Resources/config/twig/twig_hooks.yaml | 10 ++++ src/Resources/translations/messages.da.yaml | 1 + src/Resources/translations/messages.en.yaml | 1 + src/Resources/translations/messages.fr.yaml | 1 + src/Resources/translations/messages.it.yaml | 1 + src/Resources/translations/messages.nl.yaml | 1 + .../Product/add_automatic_redirect.html.twig | 8 +++ .../Taxon/add_automatic_redirect.html.twig | 8 +++ src/SlugUpdateHandler/SlugUpdateHandler.php | 2 +- .../ProductFormComponentSubscriber.php | 55 +++++++++++++++++++ .../TaxonFormComponentSubscriber.php | 55 +++++++++++++++++++ .../Constraints/InfiniteLoopValidator.php | 2 +- tests/Application/config/bundles.php | 2 + tests/Application/public/index.php | 2 +- .../Context/Transform/RedirectContext.php | 2 +- .../Ui/Admin/ManagingRedirectsContext.php | 2 +- 33 files changed, 197 insertions(+), 35 deletions(-) create mode 100644 psalm-baseline.xml create mode 100644 src/Resources/config/services/twig.xml create mode 100644 src/Resources/config/twig/twig_hooks.yaml create mode 100644 src/Resources/views/Admin/Product/add_automatic_redirect.html.twig create mode 100644 src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig create mode 100644 src/Twig/EventSubscriber/ProductFormComponentSubscriber.php create mode 100644 src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php diff --git a/README.md b/README.md index c6f44eb..2e7f05d 100644 --- a/README.md +++ b/README.md @@ -69,11 +69,7 @@ $ bin/console doctrine:migrations:diff $ bin/console doctrine:migrations:migrate ``` -### Step 5: Copy template - -You can copy the templates under `tests/Application/templates/bundles/SyliusAdminBundle` into your own application to enable the possibility to add an automatic redirection when updating product - -### Step 6: Install assets +### Step 5: Install assets ```bash $ bin/console assets:install ``` diff --git a/ecs.php b/ecs.php index 695339f..c234128 100644 --- a/ecs.php +++ b/ecs.php @@ -2,16 +2,19 @@ declare(strict_types=1); -use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\EasyCodingStandard\ValueObject\Option; +use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer; +use Symplify\EasyCodingStandard\Config\ECSConfig; -return static function (ContainerConfigurator $containerConfigurator): void { - $containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php'); - $containerConfigurator->parameters()->set(Option::PATHS, [ - 'src', 'tests' +return static function (ECSConfig $ecsConfig): void { + $ecsConfig->paths([ + __DIR__ . '/src', + __DIR__ . '/tests/', + __DIR__ . '/ecs.php', ]); - $containerConfigurator->parameters()->set(Option::SKIP, [ - 'tests/Application/**', + + $ecsConfig->import('vendor/sylius-labs/coding-standard/ecs.php'); + + $ecsConfig->skip([ + VisibilityRequiredFixer::class => ['*Spec.php'], ]); }; diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..5a97465 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,3 @@ + + + diff --git a/src/EventListener/ControllerSubscriber.php b/src/EventListener/ControllerSubscriber.php index 4dcd17a..f6ea999 100644 --- a/src/EventListener/ControllerSubscriber.php +++ b/src/EventListener/ControllerSubscriber.php @@ -31,7 +31,7 @@ final class ControllerSubscriber implements EventSubscriberInterface, LoggerAwar public function __construct( ObjectManager $objectManager, ChannelContextInterface $channelContext, - RedirectionPathResolverInterface $redirectionPathResolver + RedirectionPathResolverInterface $redirectionPathResolver, ) { $this->logger = new NullLogger(); $this->objectManager = $objectManager; @@ -57,7 +57,7 @@ public function onKernelController(ControllerEvent $event): void } $redirectionPath = $this->redirectionPathResolver->resolveFromRequest( $request, - $channel + $channel, ); if ($redirectionPath->isEmpty()) { diff --git a/src/EventListener/NotFoundSubscriber.php b/src/EventListener/NotFoundSubscriber.php index bb0ffdd..37b5cf9 100644 --- a/src/EventListener/NotFoundSubscriber.php +++ b/src/EventListener/NotFoundSubscriber.php @@ -33,7 +33,7 @@ class NotFoundSubscriber implements EventSubscriberInterface, LoggerAwareInterfa public function __construct( ObjectManager $objectManager, ChannelContextInterface $channelContext, - RedirectionPathResolverInterface $redirectionPathResolver + RedirectionPathResolverInterface $redirectionPathResolver, ) { $this->logger = new NullLogger(); $this->objectManager = $objectManager; @@ -69,7 +69,7 @@ public function onKernelException(ExceptionEvent $event): void $redirectionPath = $this->redirectionPathResolver->resolveFromRequest( $request, $channel, - true + true, ); if ($redirectionPath->isEmpty()) { diff --git a/src/EventListener/RedirectResponseTrait.php b/src/EventListener/RedirectResponseTrait.php index 321dee7..94e668c 100644 --- a/src/EventListener/RedirectResponseTrait.php +++ b/src/EventListener/RedirectResponseTrait.php @@ -25,7 +25,7 @@ public static function getRedirectResponse(RedirectInterface $lastRedirect, stri return new RedirectResponse( $uri->__toString(), - $lastRedirect->isPermanent() ? Response::HTTP_MOVED_PERMANENTLY : Response::HTTP_FOUND + $lastRedirect->isPermanent() ? Response::HTTP_MOVED_PERMANENTLY : Response::HTTP_FOUND, ); } } diff --git a/src/Factory/RedirectFactory.php b/src/Factory/RedirectFactory.php index 92a3164..69d9c2d 100644 --- a/src/Factory/RedirectFactory.php +++ b/src/Factory/RedirectFactory.php @@ -31,7 +31,7 @@ public function createNewWithValues( string $destination, bool $permanent = true, bool $only404 = true, - iterable $channels = [] + iterable $channels = [], ): RedirectInterface { $redirect = $this->createNew(); diff --git a/src/Factory/RedirectFactoryInterface.php b/src/Factory/RedirectFactoryInterface.php index 1852ef8..f9dd92e 100644 --- a/src/Factory/RedirectFactoryInterface.php +++ b/src/Factory/RedirectFactoryInterface.php @@ -20,6 +20,6 @@ public function createNewWithValues( string $destination, bool $permanent = true, bool $only404 = true, - iterable $channels = [] + iterable $channels = [], ): RedirectInterface; } diff --git a/src/Model/Redirect.php b/src/Model/Redirect.php index a7155e2..2cdcdc1 100644 --- a/src/Model/Redirect.php +++ b/src/Model/Redirect.php @@ -15,7 +15,6 @@ class Redirect implements RedirectInterface { use TimestampableTrait; - use ToggleableTrait; protected ?int $id = null; diff --git a/src/Repository/RedirectRepository.php b/src/Repository/RedirectRepository.php index 9150b1f..1211838 100644 --- a/src/Repository/RedirectRepository.php +++ b/src/Repository/RedirectRepository.php @@ -24,7 +24,7 @@ public function removeNotAccessed(int $threshold): void ->delete() ->orWhere( 'r.lastAccessed is not null and r.lastAccessed <= :threshold', - 'r.lastAccessed is null and r.createdAt <= :threshold' + 'r.lastAccessed is null and r.createdAt <= :threshold', ) ->setParameter('threshold', $dateTimeThreshold) ->getQuery() diff --git a/src/Resolver/RedirectionPathResolver.php b/src/Resolver/RedirectionPathResolver.php index dcd2778..1bbfe4d 100644 --- a/src/Resolver/RedirectionPathResolver.php +++ b/src/Resolver/RedirectionPathResolver.php @@ -22,7 +22,7 @@ public function __construct(RedirectRepositoryInterface $redirectRepository) public function resolve( string $source, ChannelInterface $channel = null, - bool $only404 = false + bool $only404 = false, ): RedirectionPath { $redirectionPath = new RedirectionPath(); @@ -39,7 +39,7 @@ public function resolve( $firstRedirect = $redirectionPath->first(); throw new InfiniteLoopException( - null !== $firstRedirect ? ($firstRedirect->getSource() ?? $source) : $source + null !== $firstRedirect ? ($firstRedirect->getSource() ?? $source) : $source, ); } } while (null !== $redirect && !$redirect->isOnly404()); // See this issue for explanation of this: https://github.com/Setono/SyliusRedirectPlugin/issues/27 @@ -50,7 +50,7 @@ public function resolve( public function resolveFromRequest( Request $request, ChannelInterface $channel = null, - bool $only404 = false + bool $only404 = false, ): RedirectionPath { return $this->resolve($request->getPathInfo(), $channel, $only404); } diff --git a/src/Resolver/RedirectionPathResolverInterface.php b/src/Resolver/RedirectionPathResolverInterface.php index fdde308..fad0f5c 100644 --- a/src/Resolver/RedirectionPathResolverInterface.php +++ b/src/Resolver/RedirectionPathResolverInterface.php @@ -22,6 +22,6 @@ public function resolve(string $source, ChannelInterface $channel = null, bool $ public function resolveFromRequest( Request $request, ChannelInterface $channel = null, - bool $only404 = false + bool $only404 = false, ): RedirectionPath; } diff --git a/src/Resources/config/admin_routing.yaml b/src/Resources/config/admin_routing.yaml index fedeceb..bb8dc1c 100644 --- a/src/Resources/config/admin_routing.yaml +++ b/src/Resources/config/admin_routing.yaml @@ -3,7 +3,7 @@ setono_sylius_redirect_admin_redirect: alias: setono_sylius_redirect.redirect section: admin permission: true - templates: "@SyliusAdmin\\Crud" + templates: "@SyliusAdmin\\shared\\crud" redirect: update grid: setono_sylius_redirect_admin_redirect vars: diff --git a/src/Resources/config/app/config.yaml b/src/Resources/config/app/config.yaml index e8382f3..6e1a5fb 100644 --- a/src/Resources/config/app/config.yaml +++ b/src/Resources/config/app/config.yaml @@ -1,2 +1,3 @@ imports: - { resource: "@SetonoSyliusRedirectPlugin/Resources/config/grids.yaml" } +- { resource: "@SetonoSyliusRedirectPlugin/Resources/config/twig/twig_hooks.yaml" } diff --git a/src/Resources/config/grids/setono_sylius_redirect_admin_redirect.yaml b/src/Resources/config/grids/setono_sylius_redirect_admin_redirect.yaml index b2ae1cf..c42aac5 100644 --- a/src/Resources/config/grids/setono_sylius_redirect_admin_redirect.yaml +++ b/src/Resources/config/grids/setono_sylius_redirect_admin_redirect.yaml @@ -16,12 +16,12 @@ sylius_grid: type: twig label: setono_sylius_redirect.ui.permanent options: - template: "@SyliusUi/Grid/Field/yesNo.html.twig" + template: "@SyliusUi/grid/field/yes_no.html.twig" enabled: type: twig label: setono_sylius_redirect.ui.enabled options: - template: "@SyliusUi/Grid/Field/yesNo.html.twig" + template: "@SyliusUi/grid/field/yes_no.html.twig" count: type: string label: setono_sylius_redirect.ui.count diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 9de70a5..275957a 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -12,5 +12,6 @@ + diff --git a/src/Resources/config/services/twig.xml b/src/Resources/config/services/twig.xml new file mode 100644 index 0000000..4b108fe --- /dev/null +++ b/src/Resources/config/services/twig.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/src/Resources/config/twig/twig_hooks.yaml b/src/Resources/config/twig/twig_hooks.yaml new file mode 100644 index 0000000..d6bee4b --- /dev/null +++ b/src/Resources/config/twig/twig_hooks.yaml @@ -0,0 +1,10 @@ +sylius_twig_hooks: + hooks: + 'sylius_admin.product.update.content.form.sections.translations': + setono_sylius_redirect_admin_redirect: + template: '@SetonoSyliusRedirectPlugin/Admin/Product/add_automatic_redirect.html.twig' + priority: 350 + 'sylius_admin.taxon.update.content.sections.form.translations': + setono_sylius_redirect_admin_redirect: + template: '@SetonoSyliusRedirectPlugin/Admin/Taxon/add_automatic_redirect.html.twig' + priority: 50 diff --git a/src/Resources/translations/messages.da.yaml b/src/Resources/translations/messages.da.yaml index 7617419..d87ee81 100644 --- a/src/Resources/translations/messages.da.yaml +++ b/src/Resources/translations/messages.da.yaml @@ -9,6 +9,7 @@ setono_sylius_redirect: new_redirect: Ny omdirigering permanent: Permanent redirects: Omdirigeringer + redirect: Omvej source: Kilde menu: admin: diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 1cbbb81..334a36b 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -9,6 +9,7 @@ setono_sylius_redirect: new_redirect: New redirect permanent: Permanent redirects: Redirects + redirect: Redirect source: Source menu: admin: diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index 910731c..c033815 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -9,6 +9,7 @@ setono_sylius_redirect: new_redirect: Créer une redirection permanent: Permanente redirects: Redirections + redirect: Redirect source: Source menu: admin: diff --git a/src/Resources/translations/messages.it.yaml b/src/Resources/translations/messages.it.yaml index 678fb12..d292f44 100644 --- a/src/Resources/translations/messages.it.yaml +++ b/src/Resources/translations/messages.it.yaml @@ -9,6 +9,7 @@ setono_sylius_redirect: new_redirect: 'Nuovo redirect' permanent: 'Permanente' redirects: 'Redirects' + redirect: 'Redirect' source: 'Provenienza' menu: admin: diff --git a/src/Resources/translations/messages.nl.yaml b/src/Resources/translations/messages.nl.yaml index c846398..71f586d 100644 --- a/src/Resources/translations/messages.nl.yaml +++ b/src/Resources/translations/messages.nl.yaml @@ -9,6 +9,7 @@ setono_sylius_redirect: new_redirect: Nieuwe omleiding permanent: Permanent redirects: Omleidingen + redirect: Omleiding source: Bron menu: admin: diff --git a/src/Resources/views/Admin/Product/add_automatic_redirect.html.twig b/src/Resources/views/Admin/Product/add_automatic_redirect.html.twig new file mode 100644 index 0000000..02324db --- /dev/null +++ b/src/Resources/views/Admin/Product/add_automatic_redirect.html.twig @@ -0,0 +1,8 @@ +{% set form = hookable_metadata.context.form %} +{% set locale = hookable_metadata.context.locale %} + +
+
+ {{ form_row(form.addAutomaticRedirect) }} +
+
diff --git a/src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig b/src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig new file mode 100644 index 0000000..02324db --- /dev/null +++ b/src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig @@ -0,0 +1,8 @@ +{% set form = hookable_metadata.context.form %} +{% set locale = hookable_metadata.context.locale %} + +
+
+ {{ form_row(form.addAutomaticRedirect) }} +
+
diff --git a/src/SlugUpdateHandler/SlugUpdateHandler.php b/src/SlugUpdateHandler/SlugUpdateHandler.php index 0cc2dbe..aab4d11 100644 --- a/src/SlugUpdateHandler/SlugUpdateHandler.php +++ b/src/SlugUpdateHandler/SlugUpdateHandler.php @@ -39,7 +39,7 @@ public function __construct( UrlGeneratorInterface $urlGenerator, RemovableRedirectFinderInterface $removableRedirectFinder, ValidatorInterface $validator, - array $validationGroups + array $validationGroups, ) { $this->redirectFactory = $redirectFactory; $this->redirectManager = $redirectManager; diff --git a/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php new file mode 100644 index 0000000..e70a6bf --- /dev/null +++ b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php @@ -0,0 +1,55 @@ + 'onPreRender']; + } + + public function onPreRender(PreRenderEvent $event): void + { + $component = $event->getComponent(); + if (!$component instanceof FormComponent) { + return; + } + + $request = $this->requestStack->getMainRequest(); + if (($request === null) || !str_ends_with($request->getRequestUri(), '/generateProductSlug')) { + return; + } + + $data = (array) json_decode((string)$request->request->get('data', '')); + /** @var string $localeCode */ + $localeCode = $data['args']['localeCode'] ?? ''; + if ($localeCode === '') { + return; + } + + $vars = $event->getVariables(); + if (!isset($vars['form']) || !$vars['form'] instanceof FormView) { + return; + } + + $addAutomaticRedirect = $vars['form']->children['translations']->children[$localeCode]->children['addAutomaticRedirect']; + if (!$addAutomaticRedirect instanceof FormView) { + return; + } + + $addAutomaticRedirect->vars['checked'] = true; + } +} diff --git a/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php new file mode 100644 index 0000000..663799c --- /dev/null +++ b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php @@ -0,0 +1,55 @@ + 'onPreRender']; + } + + public function onPreRender(PreRenderEvent $event): void + { + $component = $event->getComponent(); + if (!$component instanceof FormComponent) { + return; + } + + $request = $this->requestStack->getMainRequest(); + if (($request === null) || !str_ends_with($request->getRequestUri(), '/generateTaxonSlug')) { + return; + } + + $data = (array) json_decode((string)$request->request->get('data', '')); + /** @var string $localeCode */ + $localeCode = $data['args']['localeCode'] ?? ''; + if ($localeCode === '') { + return; + } + + $vars = $event->getVariables(); + if (!isset($vars['form']) || !$vars['form'] instanceof FormView) { + return; + } + + $addAutomaticRedirect = $vars['form']->children['translations']->children[$localeCode]->children['addAutomaticRedirect']; + if (!$addAutomaticRedirect instanceof FormView) { + return; + } + + $addAutomaticRedirect->vars['checked'] = true; + } +} diff --git a/src/Validator/Constraints/InfiniteLoopValidator.php b/src/Validator/Constraints/InfiniteLoopValidator.php index 1ec489b..b25bf91 100644 --- a/src/Validator/Constraints/InfiniteLoopValidator.php +++ b/src/Validator/Constraints/InfiniteLoopValidator.php @@ -21,7 +21,7 @@ final class InfiniteLoopValidator extends ConstraintValidator public function __construct( ChannelRepositoryInterface $channelRepository, - RedirectionPathResolverInterface $redirectionPathResolver + RedirectionPathResolverInterface $redirectionPathResolver, ) { $this->channelRepository = $channelRepository; $this->redirectionPathResolver = $redirectionPathResolver; diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index ce15ae4..5372ebc 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -1,5 +1,7 @@ ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 09d59ce..9b99fa3 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -2,9 +2,9 @@ declare(strict_types=1); -use Tests\Setono\SyliusRedirectPlugin\Application\Kernel; use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\HttpFoundation\Request; +use Tests\Setono\SyliusRedirectPlugin\Application\Kernel; require dirname(__DIR__) . '/config/bootstrap.php'; diff --git a/tests/Behat/Context/Transform/RedirectContext.php b/tests/Behat/Context/Transform/RedirectContext.php index 4e447c8..deacd9b 100644 --- a/tests/Behat/Context/Transform/RedirectContext.php +++ b/tests/Behat/Context/Transform/RedirectContext.php @@ -29,7 +29,7 @@ public function getRedirectBySource($redirect) Assert::eq( count($redirects), 1, - sprintf('%d redirects has been found with source "%s".', count($redirects), $redirect) + sprintf('%d redirects has been found with source "%s".', count($redirects), $redirect), ); return $redirects[0]; diff --git a/tests/Behat/Context/Ui/Admin/ManagingRedirectsContext.php b/tests/Behat/Context/Ui/Admin/ManagingRedirectsContext.php index 08719e3..0e1a3ca 100644 --- a/tests/Behat/Context/Ui/Admin/ManagingRedirectsContext.php +++ b/tests/Behat/Context/Ui/Admin/ManagingRedirectsContext.php @@ -67,7 +67,7 @@ public function theRedirectShouldAppearInTheStore($source, $destination): void Assert::true( $this->indexRedirectPage->theRedirectIsOnThePage($source, $destination), - sprintf('Redirect with source %s and destination %s should exist but it does not', $source, $destination) + sprintf('Redirect with source %s and destination %s should exist but it does not', $source, $destination), ); } From 18d5016ca2b65098bc9ae7386d96ac81edd7ba4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sun, 23 Mar 2025 10:15:21 +0100 Subject: [PATCH 4/9] Fix logic: only show redirect checkbox when url got changed --- .../views/Admin/Product/add_automatic_redirect.html.twig | 2 ++ .../views/Admin/Taxon/add_automatic_redirect.html.twig | 3 +++ src/Twig/EventSubscriber/ProductFormComponentSubscriber.php | 4 ++-- src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Resources/views/Admin/Product/add_automatic_redirect.html.twig b/src/Resources/views/Admin/Product/add_automatic_redirect.html.twig index 02324db..a2bfd9c 100644 --- a/src/Resources/views/Admin/Product/add_automatic_redirect.html.twig +++ b/src/Resources/views/Admin/Product/add_automatic_redirect.html.twig @@ -1,8 +1,10 @@ {% set form = hookable_metadata.context.form %} {% set locale = hookable_metadata.context.locale %} +{% if form.addAutomaticRedirect.vars['attr']['show'] is defined %}
{{ form_row(form.addAutomaticRedirect) }}
+{% endif %} diff --git a/src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig b/src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig index 02324db..bbd5cdc 100644 --- a/src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig +++ b/src/Resources/views/Admin/Taxon/add_automatic_redirect.html.twig @@ -1,8 +1,11 @@ {% set form = hookable_metadata.context.form %} {% set locale = hookable_metadata.context.locale %} + +{% if form.addAutomaticRedirect.vars['attr']['show'] is defined %}
{{ form_row(form.addAutomaticRedirect) }}
+{% endif %} diff --git a/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php index e70a6bf..650568c 100644 --- a/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php +++ b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php @@ -33,7 +33,7 @@ public function onPreRender(PreRenderEvent $event): void return; } - $data = (array) json_decode((string)$request->request->get('data', '')); + $data = (array) json_decode((string)$request->request->get('data', ''), true); /** @var string $localeCode */ $localeCode = $data['args']['localeCode'] ?? ''; if ($localeCode === '') { @@ -50,6 +50,6 @@ public function onPreRender(PreRenderEvent $event): void return; } - $addAutomaticRedirect->vars['checked'] = true; + $addAutomaticRedirect->vars['attr'] += ['show' => true]; } } diff --git a/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php index 663799c..a837c17 100644 --- a/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php +++ b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php @@ -33,7 +33,7 @@ public function onPreRender(PreRenderEvent $event): void return; } - $data = (array) json_decode((string)$request->request->get('data', '')); + $data = (array) json_decode((string)$request->request->get('data', ''), true); /** @var string $localeCode */ $localeCode = $data['args']['localeCode'] ?? ''; if ($localeCode === '') { @@ -50,6 +50,6 @@ public function onPreRender(PreRenderEvent $event): void return; } - $addAutomaticRedirect->vars['checked'] = true; + $addAutomaticRedirect->vars['attr'] += ['show' => true]; } } From c4ed5114c31ef5a4d44c3e6595dbfd20984eea13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Mon, 24 Mar 2025 14:03:37 +0100 Subject: [PATCH 5/9] Remove form template as it is not needed anymore --- src/Resources/config/admin_routing.yaml | 7 ---- .../views/Admin/Redirect/_form.html.twig | 34 ------------------- 2 files changed, 41 deletions(-) delete mode 100644 src/Resources/views/Admin/Redirect/_form.html.twig diff --git a/src/Resources/config/admin_routing.yaml b/src/Resources/config/admin_routing.yaml index bb8dc1c..ec39c57 100644 --- a/src/Resources/config/admin_routing.yaml +++ b/src/Resources/config/admin_routing.yaml @@ -6,11 +6,4 @@ setono_sylius_redirect_admin_redirect: templates: "@SyliusAdmin\\shared\\crud" redirect: update grid: setono_sylius_redirect_admin_redirect - vars: - all: - subheader: setono_sylius_redirect.ui.manage_redirects - templates: - form: "@SetonoSyliusRedirectPlugin/Admin/Redirect/_form.html.twig" - index: - icon: 'chart bar' type: sylius.resource diff --git a/src/Resources/views/Admin/Redirect/_form.html.twig b/src/Resources/views/Admin/Redirect/_form.html.twig deleted file mode 100644 index 33de454..0000000 --- a/src/Resources/views/Admin/Redirect/_form.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -
-
- {{ form_errors(form) }} -
- {{ form_row(form.source) }} - {{ form_row(form.destination) }} -
-
-
-
- {{ form_row(form.enabled) }} - {{ form_row(form.permanent) }} -
- {{ 'setono_sylius_redirect.form.redirect.permanent_help'|trans }} -
- {{ form_row(form.only404) }} -
- {{ 'setono_sylius_redirect.form.redirect.only_404_help'|trans }} -
- {{ form_row(form.keepQueryString) }} -
- {{ 'setono_sylius_redirect.form.redirect.keep_query_string_help'|trans }} -
-
-
-
-
- {{ form_row(form.channels) }} -
- {{ 'setono_sylius_redirect.form.redirect.channels_help'|trans }} -
-
-
-
From e33a3e2bc6862a7d7d65c55c6f4eb71044b465e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Wed, 28 May 2025 19:36:10 +0200 Subject: [PATCH 6/9] Update dependencies in build pipeline --- .github/workflows/build.yaml | 39 +++++-------------- composer.json | 4 +- .../ProductFormComponentSubscriber.php | 2 +- .../TaxonFormComponentSubscriber.php | 2 +- 4 files changed, 14 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4f8ce5f..6325e50 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,7 +20,7 @@ jobs: strategy: matrix: php-version: - - "7.4" # Always use the lowest version of PHP since a higher version could create actual syntax errors in lower versions + - "8.2" # Always use the lowest version of PHP since a higher version could create actual syntax errors in lower versions dependencies: - "highest" @@ -67,9 +67,6 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - - "8.1" - "8.2" - "8.3" @@ -78,12 +75,8 @@ jobs: - "highest" symfony: - - "^5.4" - - "^6.0" - - exclude: - - php-version: "7.4" - symfony: "^6.0" + - "^6.4" + - "^7.1" steps: - name: "Checkout" @@ -121,9 +114,6 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - - "8.1" - "8.2" - "8.3" @@ -132,12 +122,8 @@ jobs: - "highest" symfony: - - "^5.4" - - "^6.0" - - exclude: - - php-version: "7.4" - symfony: "^6.0" + - "^6.4" + - "^7.1" steps: - name: "Checkout" @@ -172,9 +158,6 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - - "8.1" - "8.2" - "8.3" @@ -182,12 +165,8 @@ jobs: - "highest" symfony: - - "^5.4" - - "^6.0" - - exclude: - - php-version: "7.4" - symfony: "^6.0" + - "^6.4" + - "^7.1" steps: - name: "Checkout" @@ -225,7 +204,7 @@ jobs: strategy: matrix: php-version: - - "7.4" + - "8.2" dependencies: - "highest" @@ -247,7 +226,7 @@ jobs: - name: "Setup node" uses: "actions/setup-node@v3" with: - node-version: "16" + node-version: "20" - name: "Install composer dependencies" uses: "ramsey/composer-install@v3" diff --git a/composer.json b/composer.json index 73d9f12..21dcc21 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "league/uri": "^6.0 || ^7.5", "league/uri-components": "^2.3 || ^7.5", "psr/log": "^1.1 || ^2.0 || ^3.0", + "sylius/admin-bundle": "^2.0", "sylius/channel": "^2.0", "sylius/channel-bundle": "^2.0", "sylius/core-bundle": "^2.0", @@ -32,11 +33,12 @@ "symfony/http-foundation": "^6.4 || ^7.1", "symfony/http-kernel": "^6.4 || ^7.1", "symfony/routing": "^6.4 || ^7.1", + "symfony/ux-twig-component": "^2.20", "symfony/validator": "^6.4 || ^7.1", "webmozart/assert": "^1.11" }, "require-dev": { - "api-platform/core": "^2.7", + "api-platform/core": "^4.0.3", "lexik/jwt-authentication-bundle": "^3.1", "php-http/message-factory": "^1.1", "phpspec/phpspec": "^7.3", diff --git a/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php index 650568c..6a2681b 100644 --- a/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php +++ b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php @@ -33,7 +33,7 @@ public function onPreRender(PreRenderEvent $event): void return; } - $data = (array) json_decode((string)$request->request->get('data', ''), true); + $data = (array) json_decode((string) $request->request->get('data', ''), true); /** @var string $localeCode */ $localeCode = $data['args']['localeCode'] ?? ''; if ($localeCode === '') { diff --git a/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php index a837c17..c0ad910 100644 --- a/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php +++ b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php @@ -33,7 +33,7 @@ public function onPreRender(PreRenderEvent $event): void return; } - $data = (array) json_decode((string)$request->request->get('data', ''), true); + $data = (array) json_decode((string) $request->request->get('data', ''), true); /** @var string $localeCode */ $localeCode = $data['args']['localeCode'] ?? ''; if ($localeCode === '') { From 82edf4bc82cb479a3cd3c395cc2b3adca5ba111c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Wed, 28 May 2025 20:22:12 +0200 Subject: [PATCH 7/9] Update test application to be compatible with Sylius 2.0 --- composer.json | 13 ++- src/Command/RemoveRedirectsCommand.php | 8 +- src/Resources/config/services.xml | 1 - .../config/services/block_event_listener.xml | 27 ----- tests/Application/.env | 18 ++- tests/Application/.env.test | 10 ++ tests/Application/Kernel.php | 95 ---------------- tests/Application/assets/admin/entry.js | 1 - tests/Application/assets/admin/entrypoint.js | 0 tests/Application/assets/shop/entry.js | 1 - tests/Application/assets/shop/entrypoint.js | 0 .../config/api_platform/.gitignore | 0 tests/Application/config/bootstrap.php | 6 +- tests/Application/config/bundles.php | 30 +++-- .../Application/config/packages/_sylius.yaml | 4 + .../config/packages/api_platform.yaml | 10 ++ tests/Application/config/packages/assets.yaml | 4 + .../config/packages/dev/jms_serializer.yaml | 12 -- .../config/packages/dev/swiftmailer.yaml | 2 - .../Application/config/packages/doctrine.yaml | 1 + .../config/packages/doctrine_migrations.yaml | 2 + .../Application/config/packages/fos_rest.yaml | 11 -- .../config/packages/http_discovery.yaml | 10 ++ .../config/packages/jms_serializer.yaml | 4 - tests/Application/config/packages/mailer.yaml | 3 + .../config/packages/prod/jms_serializer.yaml | 10 -- .../Application/config/packages/security.yaml | 107 +++++++----------- .../config/packages/staging/swiftmailer.yaml | 2 - .../config/packages/swiftmailer.yaml | 2 - .../sylius_state_machine_abstraction.yaml | 6 + .../config/packages/test/framework.yaml | 9 +- .../config/packages/test/security.yaml | 3 - .../config/packages/test/swiftmailer.yaml | 6 - .../config/packages/test_cached/fos_rest.yaml | 3 - .../packages/test_cached/framework.yaml | 6 +- .../config/packages/test_cached/security.yaml | 3 - .../packages/test_cached/swiftmailer.yaml | 6 - .../config/packages/twig_extensions.yaml | 11 -- .../config/packages/validator.yaml | 2 +- .../config/packages/webpack_encore.yaml | 2 + .../Application/config/packages/workflow.yaml | 2 + .../config/routes/sylius_admin.yaml | 2 +- .../Application/config/routes/sylius_api.yaml | 2 +- .../config/routes/sylius_shop.yaml | 16 ++- .../config/serialization/.gitignore | 0 tests/Application/config/services_test.yaml | 7 +- .../config/services_test_cached.yaml | 2 + tests/Application/package.json | 46 +++----- tests/Application/src/Entity/.gitignore | 0 tests/Application/webpack.config.js | 75 ++++++------ 50 files changed, 238 insertions(+), 365 deletions(-) delete mode 100644 src/Resources/config/services/block_event_listener.xml delete mode 100644 tests/Application/assets/admin/entry.js create mode 100644 tests/Application/assets/admin/entrypoint.js delete mode 100644 tests/Application/assets/shop/entry.js create mode 100644 tests/Application/assets/shop/entrypoint.js create mode 100644 tests/Application/config/api_platform/.gitignore create mode 100644 tests/Application/config/packages/api_platform.yaml delete mode 100644 tests/Application/config/packages/dev/jms_serializer.yaml delete mode 100644 tests/Application/config/packages/dev/swiftmailer.yaml delete mode 100644 tests/Application/config/packages/fos_rest.yaml create mode 100644 tests/Application/config/packages/http_discovery.yaml delete mode 100644 tests/Application/config/packages/jms_serializer.yaml create mode 100644 tests/Application/config/packages/mailer.yaml delete mode 100644 tests/Application/config/packages/prod/jms_serializer.yaml delete mode 100644 tests/Application/config/packages/staging/swiftmailer.yaml delete mode 100644 tests/Application/config/packages/swiftmailer.yaml create mode 100644 tests/Application/config/packages/sylius_state_machine_abstraction.yaml delete mode 100644 tests/Application/config/packages/test/security.yaml delete mode 100644 tests/Application/config/packages/test/swiftmailer.yaml delete mode 100644 tests/Application/config/packages/test_cached/fos_rest.yaml delete mode 100644 tests/Application/config/packages/test_cached/security.yaml delete mode 100644 tests/Application/config/packages/test_cached/swiftmailer.yaml delete mode 100644 tests/Application/config/packages/twig_extensions.yaml create mode 100644 tests/Application/config/packages/workflow.yaml create mode 100644 tests/Application/config/serialization/.gitignore create mode 100644 tests/Application/config/services_test_cached.yaml create mode 100644 tests/Application/src/Entity/.gitignore diff --git a/composer.json b/composer.json index 21dcc21..77c49d7 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,18 @@ }, "require-dev": { "api-platform/core": "^4.0.3", + "behat/behat": "^3.14", + "behat/mink-selenium2-driver": "1.6.0", + "dmore/behat-chrome-extension": "^1.4", + "dmore/chrome-mink-driver": "^2.9", + "friends-of-behat/mink": "^1.11", + "friends-of-behat/mink-browserkit-driver": "^1.6", + "friends-of-behat/mink-debug-extension": "^2.1", + "friends-of-behat/mink-extension": "^2.7", + "friends-of-behat/page-object-extension": "^0.3", + "friends-of-behat/suite-settings-extension": "^1.1", + "friends-of-behat/symfony-extension": "^2.6", + "friends-of-behat/variadic-extension": "^1.6", "lexik/jwt-authentication-bundle": "^3.1", "php-http/message-factory": "^1.1", "phpspec/phpspec": "^7.3", @@ -47,7 +59,6 @@ "psalm/plugin-phpunit": "^0.18", "psalm/plugin-symfony": "^5.0", "setono/code-quality-pack": "^2.9", - "setono/sylius-behat-pack": "^0.2", "shipmonk/composer-dependency-analyser": "^1.8", "sylius/sylius": "~2.0.0", "symfony/debug-bundle": "^6.4 || ^7.1", diff --git a/src/Command/RemoveRedirectsCommand.php b/src/Command/RemoveRedirectsCommand.php index 07def0e..152a779 100644 --- a/src/Command/RemoveRedirectsCommand.php +++ b/src/Command/RemoveRedirectsCommand.php @@ -5,16 +5,14 @@ namespace Setono\SyliusRedirectPlugin\Command; use Setono\SyliusRedirectPlugin\Repository\RedirectRepositoryInterface; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'setono:sylius-redirect:remove', description: 'This command will remove redirects that have not been accessed later than x days ago where x is the `setono_sylius_redirect.remove_after` parameter')] class RemoveRedirectsCommand extends Command { - protected static string $defaultName = 'setono:sylius-redirect:remove'; - - protected static string $defaultDescription = 'This command will remove redirects that have not been accessed later than x days ago where x is the `setono_sylius_redirect.remove_after` parameter'; - private RedirectRepositoryInterface $redirectRepository; private int $removeAfter; @@ -25,8 +23,6 @@ class RemoveRedirectsCommand extends Command public function __construct(RedirectRepositoryInterface $redirectRepository, int $removeAfter) { parent::__construct(); - $this->setName(self::$defaultName); - $this->setDescription(self::$defaultDescription); $this->redirectRepository = $redirectRepository; $this->removeAfter = $removeAfter; diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 275957a..b4d7875 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -3,7 +3,6 @@ - diff --git a/src/Resources/config/services/block_event_listener.xml b/src/Resources/config/services/block_event_listener.xml deleted file mode 100644 index 01fb828..0000000 --- a/src/Resources/config/services/block_event_listener.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - @SetonoSyliusRedirectPlugin/Admin/_javascripts.html.twig - - - - - @SetonoSyliusRedirectPlugin/Admin/Product/_javascripts.html.twig - - - - - @SetonoSyliusRedirectPlugin/Admin/Taxon/_javascripts.html.twig - - - - diff --git a/tests/Application/.env b/tests/Application/.env index 615ee1b..fd18d69 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -21,12 +21,18 @@ JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem JWT_PASSPHRASE=acme_plugin_development ###< lexik/jwt-authentication-bundle ### -###> symfony/swiftmailer-bundle ### -# For Gmail as a transport, use: "gmail://username:password@localhost" -# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" -# Delivery is disabled by default via "null://localhost" -MAILER_URL=smtp://localhost -###< symfony/swiftmailer-bundle ### +###> symfony/mailer ### +MAILER_DSN=null://null +###< symfony/mailer ### + +###> symfony/messenger ### +SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN=doctrine://default +SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN=doctrine://default?queue_name=main_failed +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN=doctrine://default?queue_name=catalog_promotion_removal +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=doctrine://default?queue_name=catalog_promotion_removal_failed +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_DSN=doctrine://default?queue_name=payment_request +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_FAILED_DSN=doctrine://default?queue_name=payment_request_failed +###< symfony/messenger ### ###> algolia/search-bundle ### ALGOLIA_APP_ID= diff --git a/tests/Application/.env.test b/tests/Application/.env.test index a683866..1ad21c4 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -1,3 +1,13 @@ APP_SECRET='ch4mb3r0f5ecr3ts' KERNEL_CLASS='Tests\Setono\SyliusRedirectPlugin\Application\Kernel' + +###> symfony/messenger ### +# Sync transport turned for testing env for the ease of testing +SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_FAILED_DSN=sync:// +###< symfony/messenger ### diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 373c8d1..a87e83e 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -4,105 +4,10 @@ namespace Tests\Setono\SyliusRedirectPlugin\Application; -use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; final class Kernel extends BaseKernel { use MicroKernelTrait; - - private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; - - public function getCacheDir(): string - { - return $this->getProjectDir() . '/var/cache/' . $this->environment; - } - - public function getLogDir(): string - { - return $this->getProjectDir() . '/var/log'; - } - - public function registerBundles(): iterable - { - foreach ($this->getConfigurationDirectories() as $confDir) { - yield from $this->registerBundlesFromFile($confDir . '/bundles.php'); - } - } - - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $container->addResource(new FileResource($confDir . '/bundles.php')); - } - - $container->setParameter('container.dumper.inline_class_loader', true); - - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadContainerConfiguration($loader, $confDir); - } - } - - protected function configureRoutes(RouteCollectionBuilder $routes): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadRoutesConfiguration($routes, $confDir); - } - } - - protected function getContainerBaseClass(): string - { - if ($this->isTestEnvironment()) { - return MockerContainer::class; - } - - return parent::getContainerBaseClass(); - } - - private function isTestEnvironment(): bool - { - return 0 === strpos($this->getEnvironment(), 'test'); - } - - private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void - { - $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); - } - - private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void - { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); - } - - /** - * @return BundleInterface[] - */ - private function registerBundlesFromFile(string $bundlesFile): iterable - { - $contents = require $bundlesFile; - foreach ($contents as $class => $envs) { - if (isset($envs['all']) || isset($envs[$this->environment])) { - yield new $class(); - } - } - } - - /** - * @return string[] - */ - private function getConfigurationDirectories(): iterable - { - yield $this->getProjectDir() . '/config'; - } } diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js deleted file mode 100644 index 635f5ac..0000000 --- a/tests/Application/assets/admin/entry.js +++ /dev/null @@ -1 +0,0 @@ -import 'sylius/bundle/AdminBundle/Resources/private/entry'; diff --git a/tests/Application/assets/admin/entrypoint.js b/tests/Application/assets/admin/entrypoint.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js deleted file mode 100644 index aadc317..0000000 --- a/tests/Application/assets/shop/entry.js +++ /dev/null @@ -1 +0,0 @@ -import 'sylius/bundle/ShopBundle/Resources/private/entry'; diff --git a/tests/Application/assets/shop/entrypoint.js b/tests/Application/assets/shop/entrypoint.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/api_platform/.gitignore b/tests/Application/config/api_platform/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index 2291ab4..b203ae2 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -13,9 +13,13 @@ $_ENV += $env; } elseif (!class_exists(Dotenv::class)) { throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} elseif (method_exists(Dotenv::class, 'bootEnv')) { + (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); + + return; } else { // load all the .env files - (new Dotenv())->loadEnv(dirname(__DIR__) . '/.env'); + (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); } $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 5372ebc..e4f43f9 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -2,11 +2,10 @@ declare(strict_types=1); -return [ +$bundles = [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], @@ -32,11 +31,6 @@ Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], Setono\SyliusRedirectPlugin\SetonoSyliusRedirectPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], - winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true], - Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true], - Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true], - JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true], - FOS\RestBundle\FOSRestBundle::class => ['all' => true], Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], @@ -50,12 +44,26 @@ Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], - Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], + FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], + ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], + Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], - FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], + Sylius\TwigExtra\Symfony\SyliusTwigExtraBundle::class => ['all' => true], + Sylius\TwigHooks\SyliusTwigHooksBundle::class => ['all' => true], + Symfony\UX\Icons\UXIconsBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], + Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true], + Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true], + Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], ]; + +if (class_exists(winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class)) { + $bundles[winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class] = ['all' => true]; +} + +return $bundles; diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 23195a4..b2ba98f 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -1,5 +1,6 @@ imports: - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } + - { resource: "@SyliusPayumBundle/Resources/config/app/config.yaml" } - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } @@ -10,3 +11,6 @@ parameters: sylius_shop: product_grid: include_all_descendants: true + +sylius_api: + enabled: true diff --git a/tests/Application/config/packages/api_platform.yaml b/tests/Application/config/packages/api_platform.yaml new file mode 100644 index 0000000..ceb10e7 --- /dev/null +++ b/tests/Application/config/packages/api_platform.yaml @@ -0,0 +1,10 @@ +api_platform: + mapping: + paths: + - '%kernel.project_dir%/../../vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_platform' + - '%kernel.project_dir%/config/api_platform' + - '%kernel.project_dir%/src/Entity' + patch_formats: + json: ['application/merge-patch+json'] + swagger: + versions: [3] diff --git a/tests/Application/config/packages/assets.yaml b/tests/Application/config/packages/assets.yaml index 2468901..73f9d56 100644 --- a/tests/Application/config/packages/assets.yaml +++ b/tests/Application/config/packages/assets.yaml @@ -5,3 +5,7 @@ framework: json_manifest_path: '%kernel.project_dir%/public/build/shop/manifest.json' admin: json_manifest_path: '%kernel.project_dir%/public/build/admin/manifest.json' + app.admin: + json_manifest_path: '%kernel.project_dir%/public/build/app/admin/manifest.json' + app.shop: + json_manifest_path: '%kernel.project_dir%/public/build/app/shop/manifest.json' diff --git a/tests/Application/config/packages/dev/jms_serializer.yaml b/tests/Application/config/packages/dev/jms_serializer.yaml deleted file mode 100644 index 2f32a9b..0000000 --- a/tests/Application/config/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/packages/dev/swiftmailer.yaml deleted file mode 100644 index f438078..0000000 --- a/tests/Application/config/packages/dev/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/packages/doctrine.yaml b/tests/Application/config/packages/doctrine.yaml index 059089f..f51ba5a 100644 --- a/tests/Application/config/packages/doctrine.yaml +++ b/tests/Application/config/packages/doctrine.yaml @@ -10,4 +10,5 @@ doctrine: driver: 'pdo_mysql' server_version: '5.7' charset: UTF8 + url: '%env(resolve:DATABASE_URL)%' diff --git a/tests/Application/config/packages/doctrine_migrations.yaml b/tests/Application/config/packages/doctrine_migrations.yaml index cdbc01a..ec35649 100644 --- a/tests/Application/config/packages/doctrine_migrations.yaml +++ b/tests/Application/config/packages/doctrine_migrations.yaml @@ -2,3 +2,5 @@ doctrine_migrations: storage: table_storage: table_name: sylius_migrations + migrations_paths: + 'App\Migrations': '%kernel.project_dir%/../../src/Migrations/' diff --git a/tests/Application/config/packages/fos_rest.yaml b/tests/Application/config/packages/fos_rest.yaml deleted file mode 100644 index a72eef7..0000000 --- a/tests/Application/config/packages/fos_rest.yaml +++ /dev/null @@ -1,11 +0,0 @@ -fos_rest: - exception: true - view: - formats: - json: true - xml: true - empty_content: 204 - format_listener: - rules: - - { path: '^/api/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true } - - { path: '^/', stop: true } diff --git a/tests/Application/config/packages/http_discovery.yaml b/tests/Application/config/packages/http_discovery.yaml new file mode 100644 index 0000000..2a789e7 --- /dev/null +++ b/tests/Application/config/packages/http_discovery.yaml @@ -0,0 +1,10 @@ +services: + Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory' + + http_discovery.psr17_factory: + class: Http\Discovery\Psr17Factory diff --git a/tests/Application/config/packages/jms_serializer.yaml b/tests/Application/config/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc61..0000000 --- a/tests/Application/config/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml new file mode 100644 index 0000000..56a650d --- /dev/null +++ b/tests/Application/config/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/packages/prod/jms_serializer.yaml b/tests/Application/config/packages/prod/jms_serializer.yaml deleted file mode 100644 index c288182..0000000 --- a/tests/Application/config/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml index 1185f86..af38e75 100644 --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -1,12 +1,4 @@ -parameters: - sylius.security.admin_regex: "^/admin" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!admin|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - security: - always_authenticate_before_granting: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -16,11 +8,8 @@ security: id: sylius.shop_user_provider.email_or_name_based sylius_api_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - encoders: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -28,6 +17,7 @@ security: context: admin pattern: "%sylius.security.admin_regex%" provider: sylius_admin_user_provider + user_checker: security.user_checker.chain.admin form_login: provider: sylius_admin_user_provider login_path: sylius_admin_login @@ -36,74 +26,53 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: secret: "%env(APP_SECRET)%" - path: /admin + path: "/%sylius_admin.path_name%" name: APP_ADMIN_REMEMBER_ME lifetime: 31536000 remember_me_parameter: _remember_me logout: path: sylius_admin_logout target: sylius_admin_login - anonymous: true - - oauth_token: - pattern: "%sylius.security.api_regex%/oauth/v2/token" - security: false - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider + api_admin: + pattern: "%sylius.security.api_admin_regex%/.*" + provider: sylius_api_admin_user_provider + user_checker: security.user_checker.chain.api_admin stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" + check_path: "%sylius.security.api_admin_route%/administrators/token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider + api_shop: + pattern: "%sylius.security.api_shop_regex%/.*" + provider: sylius_api_shop_user_provider + user_checker: security.user_checker.chain.api_shop stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" + check_path: "%sylius.security.api_shop_route%/customers/token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - api: - pattern: "%sylius.security.api_regex%/.*" - provider: sylius_admin_user_provider - stateless: true - anonymous: true + jwt: true shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } context: shop pattern: "%sylius.security.shop_regex%" provider: sylius_shop_user_provider + user_checker: security.user_checker.chain.shop form_login: success_handler: sylius.authentication.success_handler failure_handler: sylius.authentication.failure_handler @@ -114,9 +83,15 @@ security: default_target_path: sylius_shop_homepage use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate + json_login: + check_path: sylius_shop_json_login_check + username_path: _username + password_path: _password + success_handler: sylius.authentication.success_handler + failure_handler: sylius.authentication.failure_handler remember_me: secret: "%env(APP_SECRET)%" name: APP_SHOP_REMEMBER_ME @@ -124,28 +99,32 @@ security: remember_me_parameter: _remember_me logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true + + image_resolver: + pattern: ^/media/cache/resolve + security: false dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } + - { path: "%sylius.security.admin_regex%/forgotten-password", role: PUBLIC_ACCESS } - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.api_admin_route%/administrators/reset-password", role: PUBLIC_ACCESS } + - { path: "%sylius.security.api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.api_admin_route%/administrators/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.api_shop_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.api_shop_route%/customers/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/packages/staging/swiftmailer.yaml deleted file mode 100644 index f438078..0000000 --- a/tests/Application/config/packages/staging/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/packages/swiftmailer.yaml b/tests/Application/config/packages/swiftmailer.yaml deleted file mode 100644 index 3bab0d3..0000000 --- a/tests/Application/config/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)%' diff --git a/tests/Application/config/packages/sylius_state_machine_abstraction.yaml b/tests/Application/config/packages/sylius_state_machine_abstraction.yaml new file mode 100644 index 0000000..7f43c0b --- /dev/null +++ b/tests/Application/config/packages/sylius_state_machine_abstraction.yaml @@ -0,0 +1,6 @@ +parameters: + test_default_state_machine_adapter: 'symfony_workflow' + test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%' + +sylius_state_machine_abstraction: + default_adapter: '%test_sylius_state_machine_adapter%' diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e..e71603c 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,11 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file + + mailer: + dsn: '%env(MAILER_DSN)%' + cache: + pools: + test.mailer_pool: + adapter: cache.adapter.filesystem diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml deleted file mode 100644 index 21cc377..0000000 --- a/tests/Application/config/packages/test/security.yaml +++ /dev/null @@ -1,3 +0,0 @@ -security: - encoders: - sha512: sha512 diff --git a/tests/Application/config/packages/test/swiftmailer.yaml b/tests/Application/config/packages/test/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/packages/test/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/packages/test_cached/fos_rest.yaml b/tests/Application/config/packages/test_cached/fos_rest.yaml deleted file mode 100644 index 2b4189d..0000000 --- a/tests/Application/config/packages/test_cached/fos_rest.yaml +++ /dev/null @@ -1,3 +0,0 @@ -fos_rest: - exception: - debug: true diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e..e9dd6ee 100644 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -1,4 +1,2 @@ -framework: - test: ~ - session: - storage_id: session.storage.mock_file +imports: + - { resource: ../test/framework.yaml } diff --git a/tests/Application/config/packages/test_cached/security.yaml b/tests/Application/config/packages/test_cached/security.yaml deleted file mode 100644 index 21cc377..0000000 --- a/tests/Application/config/packages/test_cached/security.yaml +++ /dev/null @@ -1,3 +0,0 @@ -security: - encoders: - sha512: sha512 diff --git a/tests/Application/config/packages/test_cached/swiftmailer.yaml b/tests/Application/config/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/packages/test_cached/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/packages/twig_extensions.yaml b/tests/Application/config/packages/twig_extensions.yaml deleted file mode 100644 index 0881cc9..0000000 --- a/tests/Application/config/packages/twig_extensions.yaml +++ /dev/null @@ -1,11 +0,0 @@ -services: - _defaults: - public: false - autowire: true - autoconfigure: true - - # Uncomment any lines below to activate that Twig extension - #Twig\Extensions\ArrayExtension: ~ - #Twig\Extensions\DateExtension: ~ - #Twig\Extensions\IntlExtension: ~ - #Twig\Extensions\TextExtension: ~ diff --git a/tests/Application/config/packages/validator.yaml b/tests/Application/config/packages/validator.yaml index 61807db..a695e1a 100644 --- a/tests/Application/config/packages/validator.yaml +++ b/tests/Application/config/packages/validator.yaml @@ -1,3 +1,3 @@ framework: validation: - enable_annotations: true + email_validation_mode: html5 diff --git a/tests/Application/config/packages/webpack_encore.yaml b/tests/Application/config/packages/webpack_encore.yaml index 9bee248..23ddaa2 100644 --- a/tests/Application/config/packages/webpack_encore.yaml +++ b/tests/Application/config/packages/webpack_encore.yaml @@ -3,3 +3,5 @@ webpack_encore: builds: shop: '%kernel.project_dir%/public/build/shop' admin: '%kernel.project_dir%/public/build/admin' + app.admin: '%kernel.project_dir%/public/build/app/admin' + app.shop: '%kernel.project_dir%/public/build/app/shop' diff --git a/tests/Application/config/packages/workflow.yaml b/tests/Application/config/packages/workflow.yaml new file mode 100644 index 0000000..2a716ff --- /dev/null +++ b/tests/Application/config/packages/workflow.yaml @@ -0,0 +1,2 @@ +framework: + workflows: ~ diff --git a/tests/Application/config/routes/sylius_admin.yaml b/tests/Application/config/routes/sylius_admin.yaml index 1ba48d6..b9c12c2 100644 --- a/tests/Application/config/routes/sylius_admin.yaml +++ b/tests/Application/config/routes/sylius_admin.yaml @@ -1,3 +1,3 @@ sylius_admin: resource: "@SyliusAdminBundle/Resources/config/routing.yml" - prefix: /admin + prefix: '/%sylius_admin.path_name%' diff --git a/tests/Application/config/routes/sylius_api.yaml b/tests/Application/config/routes/sylius_api.yaml index ae01ffc..a7504e8 100644 --- a/tests/Application/config/routes/sylius_api.yaml +++ b/tests/Application/config/routes/sylius_api.yaml @@ -1,3 +1,3 @@ sylius_api: resource: "@SyliusApiBundle/Resources/config/routing.yml" - prefix: "%sylius.security.new_api_route%" + prefix: "%sylius.security.api_route%" diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml index 92eeae0..8e3dd42 100644 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -5,10 +5,22 @@ sylius_shop: _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ sylius_shop_payum: - resource: "@SyliusShopBundle/Resources/config/routing/payum.yml" + resource: "@SyliusPayumBundle/Resources/config/routing/integrations/sylius_shop.yaml" + +sylius_payment_notify: + resource: "@SyliusPaymentBundle/Resources/config/routing/integrations/sylius.yaml" sylius_shop_default_locale: path: / methods: [GET] defaults: - _controller: sylius.controller.shop.locale_switch:switchAction + _controller: sylius_shop.controller.locale_switch::switchAction + +# see https://web.dev/change-password-url/ +sylius_shop_request_password_reset_token_redirect: + path: /.well-known/change-password + methods: [GET] + controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction + defaults: + route: sylius_shop_request_password_reset_token + permanent: false diff --git a/tests/Application/config/serialization/.gitignore b/tests/Application/config/serialization/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/services_test.yaml b/tests/Application/config/services_test.yaml index d9b02e3..d072d89 100644 --- a/tests/Application/config/services_test.yaml +++ b/tests/Application/config/services_test.yaml @@ -1,3 +1,8 @@ imports: - - { resource: "../../Behat/Resources/services.xml" } - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } + - { resource: "../../Behat/Resources/services.xml" } + +# workaround needed for strange "test.client.history" problem +# see https://github.com/FriendsOfBehat/SymfonyExtension/issues/88 +services: + Symfony\Component\BrowserKit\AbstractBrowser: '@test.client' diff --git a/tests/Application/config/services_test_cached.yaml b/tests/Application/config/services_test_cached.yaml new file mode 100644 index 0000000..0de380e --- /dev/null +++ b/tests/Application/config/services_test_cached.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "services_test.yaml" } diff --git a/tests/Application/package.json b/tests/Application/package.json index e990ba4..b91df2a 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,30 +1,20 @@ { - "dependencies": { - "chart.js": "^2.9", - "jquery": "^3.6", - "jquery.dirtyforms": "^2.0", - "lightbox2": "^2.9", - "semantic-ui-css": "^2.2", - "slick-carousel": "^1.8" - }, - "devDependencies": { - "@symfony/webpack-encore": "^1.8", - "eslint": "^8.18", - "eslint-config-airbnb-base": "^15.0", - "eslint-import-resolver-babel-module": "^5.3", - "eslint-plugin-import": "^2.26", - "node-sass": "^7.0", - "sass-loader": "^12.0" - }, - "scripts": { - "dev": "encore dev", - "build": "encore production", - "watch": "encore dev --watch" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Sylius/Sylius.git" - }, - "author": "Paweł Jędrzejewski", - "license": "MIT" + "license": "UNLICENSED", + "scripts": { + "build": "encore dev", + "build:prod": "encore production", + "watch": "encore dev --watch" + }, + "dependencies": { + "@sylius-ui/admin": "file:../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle", + "@sylius-ui/shop": "file:../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle", + "@symfony/ux-autocomplete": "file:../../vendor/symfony/ux-autocomplete/assets", + "@symfony/ux-live-component": "file:../../vendor/symfony/ux-live-component/assets" + }, + "devDependencies": { + "@hotwired/stimulus": "^3.0.0", + "@symfony/stimulus-bridge": "^3.2.0", + "@symfony/webpack-encore": "^5.0.1", + "tom-select": "^2.2.2" + } } diff --git a/tests/Application/src/Entity/.gitignore b/tests/Application/src/Entity/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index fae1429..b19eb22 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -1,47 +1,48 @@ const path = require('path'); const Encore = require('@symfony/webpack-encore'); -const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/'); -const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/'); -const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/'); +const SyliusAdmin = require('@sylius-ui/admin'); +const SyliusShop = require('@sylius-ui/shop'); + +// Admin config +const adminConfig = SyliusAdmin.getWebpackConfig(path.resolve(__dirname)); // Shop config +const shopConfig = SyliusShop.getWebpackConfig(path.resolve(__dirname)); + +// App shop config Encore - .setOutputPath('public/build/shop/') - .setPublicPath('/build/shop') - .addEntry('shop-entry', './assets/shop/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); - -const shopConfig = Encore.getWebpackConfig(); - -shopConfig.resolve.alias['sylius/ui'] = uiBundleScripts; -shopConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; -shopConfig.resolve.alias['sylius/bundle'] = syliusBundles; -shopConfig.name = 'shop'; + .setOutputPath('public/build/app/shop') + .setPublicPath('/build/app/shop') + .addEntry('app-shop-entry', './assets/shop/entrypoint.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader() +; + +const appShopConfig = Encore.getWebpackConfig(); + +appShopConfig.externals = Object.assign({}, appShopConfig.externals, { window: 'window', document: 'document' }); +appShopConfig.name = 'app.shop'; Encore.reset(); -// Admin config +// App admin config Encore - .setOutputPath('public/build/admin/') - .setPublicPath('/build/admin') - .addEntry('admin-entry', './assets/admin/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); - -const adminConfig = Encore.getWebpackConfig(); - -adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; -adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; -adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; -adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); -adminConfig.name = 'admin'; - -module.exports = [shopConfig, adminConfig]; + .setOutputPath('public/build/app/admin') + .setPublicPath('/build/app/admin') + .addEntry('app-admin-entry', './assets/admin/entrypoint.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); + +const appAdminConfig = Encore.getWebpackConfig(); + +appAdminConfig.externals = Object.assign({}, appAdminConfig.externals, { window: 'window', document: 'document' }); +appAdminConfig.name = 'app.admin'; + +module.exports = [shopConfig, adminConfig, appShopConfig, appAdminConfig]; From bad6fc878476d7d0207fb806601e7dc98694c013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Wed, 25 Jun 2025 19:59:15 +0200 Subject: [PATCH 8/9] Remove psalm/plugin-symfony due to incompatibility --- composer.json | 1 - psalm.xml | 1 - 2 files changed, 2 deletions(-) diff --git a/composer.json b/composer.json index 77c49d7..9be972d 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,6 @@ "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.6", "psalm/plugin-phpunit": "^0.18", - "psalm/plugin-symfony": "^5.0", "setono/code-quality-pack": "^2.9", "shipmonk/composer-dependency-analyser": "^1.8", "sylius/sylius": "~2.0.0", diff --git a/psalm.xml b/psalm.xml index a1daf98..f6ec576 100644 --- a/psalm.xml +++ b/psalm.xml @@ -19,7 +19,6 @@ - From 1e8863659ffa53813d593b8cb015704eb6065ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Wed, 25 Jun 2025 20:26:44 +0200 Subject: [PATCH 9/9] Ignore Psalm findings --- src/Twig/EventSubscriber/ProductFormComponentSubscriber.php | 5 +++++ src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php | 5 +++++ src/Validator/Constraints/InfiniteLoopValidator.php | 1 + src/Validator/Constraints/SourceRegexValidator.php | 1 + src/Validator/Constraints/SourceValidator.php | 1 + 5 files changed, 13 insertions(+) diff --git a/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php index 6a2681b..6a41daa 100644 --- a/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php +++ b/src/Twig/EventSubscriber/ProductFormComponentSubscriber.php @@ -50,6 +50,11 @@ public function onPreRender(PreRenderEvent $event): void return; } + /** + * @psalm-suppress MixedOperand + * @psalm-suppress MixedArrayAccess + * @psalm-suppress MixedArrayAssignment + */ $addAutomaticRedirect->vars['attr'] += ['show' => true]; } } diff --git a/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php index c0ad910..17edbab 100644 --- a/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php +++ b/src/Twig/EventSubscriber/TaxonFormComponentSubscriber.php @@ -50,6 +50,11 @@ public function onPreRender(PreRenderEvent $event): void return; } + /** + * @psalm-suppress MixedOperand + * @psalm-suppress MixedArrayAccess + * @psalm-suppress MixedArrayAssignment + */ $addAutomaticRedirect->vars['attr'] += ['show' => true]; } } diff --git a/src/Validator/Constraints/InfiniteLoopValidator.php b/src/Validator/Constraints/InfiniteLoopValidator.php index b25bf91..fac77d0 100644 --- a/src/Validator/Constraints/InfiniteLoopValidator.php +++ b/src/Validator/Constraints/InfiniteLoopValidator.php @@ -13,6 +13,7 @@ use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; +/** @psalm-suppress PropertyNotSetInConstructor */ final class InfiniteLoopValidator extends ConstraintValidator { private ChannelRepositoryInterface $channelRepository; diff --git a/src/Validator/Constraints/SourceRegexValidator.php b/src/Validator/Constraints/SourceRegexValidator.php index 3486c43..8ae4239 100644 --- a/src/Validator/Constraints/SourceRegexValidator.php +++ b/src/Validator/Constraints/SourceRegexValidator.php @@ -8,6 +8,7 @@ use Symfony\Component\Validator\Constraints\RegexValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; +/** @psalm-suppress PropertyNotSetInConstructor */ final class SourceRegexValidator extends RegexValidator { private string $pattern; diff --git a/src/Validator/Constraints/SourceValidator.php b/src/Validator/Constraints/SourceValidator.php index 8710737..29cb36c 100644 --- a/src/Validator/Constraints/SourceValidator.php +++ b/src/Validator/Constraints/SourceValidator.php @@ -10,6 +10,7 @@ use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; +/** @psalm-suppress PropertyNotSetInConstructor */ final class SourceValidator extends ConstraintValidator { private RedirectRepositoryInterface $redirectRepository;