From d54e6112b4efa6a693eea52aa52264ab53342e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sun, 23 Mar 2025 10:25:45 +0100 Subject: [PATCH 1/9] Sylius 2.x dependency upgrade --- composer.json | 59 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/composer.json b/composer.json index d65023c..0992f44 100644 --- a/composer.json +++ b/composer.json @@ -9,54 +9,54 @@ "terms" ], "require": { - "php": ">=8.1", - "doctrine/collections": "^1.6", + "php": ">=8.2", + "doctrine/collections": "^2.2", "doctrine/orm": "^2.7", "fakerphp/faker": "^1.23", "knplabs/knp-menu": "^3.1", - "sylius/channel": "^1.0", - "sylius/channel-bundle": "^1.0", - "sylius/core": "^1.0", - "sylius/core-bundle": "^1.0", - "sylius/locale": "^1.0", - "sylius/resource-bundle": "^1.6", - "sylius/ui-bundle": "^1.0", - "symfony/config": "^5.4 || ^6.4 || ^7.0", - "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0", - "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0", - "symfony/form": "^5.4 || ^6.4 || ^7.0", - "symfony/http-foundation": "^5.4 || ^6.4 || ^7.0", - "symfony/http-kernel": "^5.4 || ^6.4 || ^7.0", - "symfony/options-resolver": "^5.4 || ^6.4 || ^7.0", - "symfony/routing": "^5.4 || ^6.4 || ^7.0", - "symfony/string": "^5.4 || ^6.4 || ^7.0", + "sylius/channel": "^2.0", + "sylius/channel-bundle": "^2.0", + "sylius/core": "^2.0", + "sylius/core-bundle": "^2.0", + "sylius/locale": "^2.0", + "sylius/resource-bundle": "^1.12", + "sylius/ui-bundle": "^2.0", + "symfony/config": "^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/options-resolver": "^6.4 || ^7.1", + "symfony/routing": "^6.4 || ^7.1", + "symfony/string": "^6.4 || ^7.1", "symfony/translation-contracts": "^1.1 || ^2.4 || ^3.4", - "symfony/validator": "^5.4 || ^6.4 || ^7.0", + "symfony/validator": "^6.4 || ^7.1", "twig/twig": "^2.14 || ^3.8", "webmozart/assert": "^1.11" }, "require-dev": { "api-platform/core": "^2.7.16", - "babdev/pagerfanta-bundle": "^3.8", + "babdev/pagerfanta-bundle": "^4.4", "behat/behat": "^3.14", "doctrine/doctrine-bundle": "^2.11", "infection/infection": "^0.27.9", "jms/serializer-bundle": "^4.2", - "lexik/jwt-authentication-bundle": "^2.17", + "lexik/jwt-authentication-bundle": "^3.1", "matthiasnoback/symfony-config-test": "^4.3 || ^5.1", "matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6", "psalm/plugin-phpunit": "^0.18", "setono/code-quality-pack": "^2.7", - "sylius/sylius": "~1.12.13", - "symfony/debug-bundle": "^5.4 || ^6.4 || ^7.0", - "symfony/dotenv": "^5.4 || ^6.4 || ^7.0", - "symfony/intl": "^5.4 || ^6.4 || ^7.0", - "symfony/property-info": "^5.4 || ^6.4 || ^7.0", - "symfony/serializer": "^5.4 || ^6.4 || ^7.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.4 || ^7.0", - "symfony/webpack-encore-bundle": "^1.17", + "sylius/sylius": "~2.0", + "symfony/debug-bundle": "^6.4 || ^7.1", + "symfony/dotenv": "^6.4 || ^7.1", + "symfony/intl": "^6.4 || ^7.1", + "symfony/property-info": "^6.4 || ^7.1", + "symfony/serializer": "^6.4 || ^7.1", + "symfony/web-profiler-bundle": "^6.4 || ^7.1", + "symfony/webpack-encore-bundle": "^2.2", "willdurand/negotiation": "^3.1" }, "prefer-stable": true, @@ -78,6 +78,7 @@ "dealerdirect/phpcodesniffer-composer-installer": false, "ergebnis/composer-normalize": true, "infection/extension-installer": true, + "php-http/discovery": true, "symfony/thanks": false }, "sort-packages": true From 48926fb309e48b467d551ace50896c81f31d29ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sun, 23 Mar 2025 14:36:22 +0100 Subject: [PATCH 2/9] Make Admin UI work in Sylius 2.x --- .../SetonoSyliusTermsExtension.php | 4 +- src/Resources/config/app/config.yaml | 2 + src/Resources/config/routes/admin.yaml | 10 +---- src/Resources/config/twig/twig_hooks.yaml | 20 +++++++++ .../views/admin/terms/_form.html.twig | 41 ++++++++++++------- .../views/admin/terms/form/left.html.twig | 18 ++++++++ .../views/admin/terms/form/right.html.twig | 5 +++ 7 files changed, 76 insertions(+), 24 deletions(-) create mode 100644 src/Resources/config/app/config.yaml create mode 100644 src/Resources/config/twig/twig_hooks.yaml create mode 100644 src/Resources/views/admin/terms/form/left.html.twig create mode 100644 src/Resources/views/admin/terms/form/right.html.twig diff --git a/src/DependencyInjection/SetonoSyliusTermsExtension.php b/src/DependencyInjection/SetonoSyliusTermsExtension.php index 56a3a76..dd145c0 100644 --- a/src/DependencyInjection/SetonoSyliusTermsExtension.php +++ b/src/DependencyInjection/SetonoSyliusTermsExtension.php @@ -91,7 +91,7 @@ public function prepend(ContainerBuilder $container): void ], ]); - $container->prependExtensionConfig('sylius_ui', [ + /*$container->prependExtensionConfig('sylius_ui', [ 'events' => [ 'setono_sylius_terms.admin.terms.create.javascripts' => [ 'blocks' => [ @@ -101,6 +101,6 @@ public function prepend(ContainerBuilder $container): void ], ], ], - ]); + ]);*/ } } diff --git a/src/Resources/config/app/config.yaml b/src/Resources/config/app/config.yaml new file mode 100644 index 0000000..a60ae26 --- /dev/null +++ b/src/Resources/config/app/config.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "@SetonoSyliusTermsPlugin/Resources/config/twig/twig_hooks.yaml" } diff --git a/src/Resources/config/routes/admin.yaml b/src/Resources/config/routes/admin.yaml index c232c0a..d02b462 100644 --- a/src/Resources/config/routes/admin.yaml +++ b/src/Resources/config/routes/admin.yaml @@ -2,14 +2,8 @@ setono_sylius_terms_admin_terms: resource: | alias: setono_sylius_terms.terms section: admin - templates: "@SyliusAdmin\\Crud" + templates: "@SyliusAdmin\\shared\\crud" redirect: update + except: [show] grid: setono_sylius_terms_terms - vars: - all: - subheader: setono_sylius_terms.ui.manage_terms - templates: - form: "@SetonoSyliusTermsPlugin/admin/terms/_form.html.twig" - index: - icon: 'check circle outline' type: sylius.resource diff --git a/src/Resources/config/twig/twig_hooks.yaml b/src/Resources/config/twig/twig_hooks.yaml new file mode 100644 index 0000000..2ecf944 --- /dev/null +++ b/src/Resources/config/twig/twig_hooks.yaml @@ -0,0 +1,20 @@ +sylius_twig_hooks: + hooks: + 'sylius_admin.terms.create.content': + form: + template: '@SetonoSyliusTermsPlugin/admin/terms/_form.html.twig' + 'sylius_admin.terms.create.content.form#left': + form: + template: '@SetonoSyliusTermsPlugin/admin/terms/form/left.html.twig' + 'sylius_admin.terms.create.content.form#right': + form: + template: '@SetonoSyliusTermsPlugin/admin/terms/form/right.html.twig' + 'sylius_admin.terms.update.content': + form: + template: '@SetonoSyliusTermsPlugin/admin/terms/_form.html.twig' + 'sylius_admin.terms.update.content.form#left': + form: + template: '@SetonoSyliusTermsPlugin/admin/terms/form/left.html.twig' + 'sylius_admin.terms.update.content.form#right': + form: + template: '@SetonoSyliusTermsPlugin/admin/terms/form/right.html.twig' diff --git a/src/Resources/views/admin/terms/_form.html.twig b/src/Resources/views/admin/terms/_form.html.twig index 27a7c6c..4091010 100644 --- a/src/Resources/views/admin/terms/_form.html.twig +++ b/src/Resources/views/admin/terms/_form.html.twig @@ -1,20 +1,33 @@ -{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationFormWithSlug %} +{% if form is not defined %} + {% set form = hookable_metadata.context.form %} +{% endif %} -
-
- {{ form_errors(form) }} +{% if resource is not defined %} + {% set resource = hookable_metadata.context.resource|default(null) %} +{% endif %} -
- {{ form_row(form.code) }} - {{ form_row(form.enabled) }} -
- {{ form_row(form.forms) }} - {{ form_row(form.channels) }} -
+{% form_theme form '@SyliusAdmin/shared/form_theme.html.twig' %} +
+ {{ form_start(form, {'attr': {'novalidate': 'novalidate', 'id': form.vars.id}}) }} + {% if hookable_metadata.configuration.method is defined %} + + {% elseif form.vars.data.id|default(null) is not null %} + + {% endif %} + {{ form_errors(form) }} + {{ form_widget(form._token) }} +
+
+
+ {% hook 'form#left' with { form, resource } %} +
+
+
+
+ {% hook 'form#right' with { form, resource } %} +
-
- {{ translationFormWithSlug(form.translations, '@SyliusAdmin/Product/_slugField.html.twig', terms) }} -
+ {{ form_end(form, {render_rest: hookable_metadata.configuration.render_rest|default(false)}) }}
diff --git a/src/Resources/views/admin/terms/form/left.html.twig b/src/Resources/views/admin/terms/form/left.html.twig new file mode 100644 index 0000000..95cdb19 --- /dev/null +++ b/src/Resources/views/admin/terms/form/left.html.twig @@ -0,0 +1,18 @@ +
+
+
{{ form_row(hookable_metadata.context.form.code) }}
+
+
+
+
+
{{ form_row(hookable_metadata.context.form.enabled) }}
+
+
+
+
+
{{ form_row(hookable_metadata.context.form.forms) }}
+
+
+
{{ form_row(hookable_metadata.context.form.channels) }}
+
+
diff --git a/src/Resources/views/admin/terms/form/right.html.twig b/src/Resources/views/admin/terms/form/right.html.twig new file mode 100644 index 0000000..e1da9a3 --- /dev/null +++ b/src/Resources/views/admin/terms/form/right.html.twig @@ -0,0 +1,5 @@ +
+
+ {{ form_row(hookable_metadata.context.form.translations) }} +
+
From 4d73003ec99bcbd6f6d6a270ece613bc21e408c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Mon, 24 Mar 2025 16:43:24 +0100 Subject: [PATCH 3/9] Make Admin UI compatible with Sylius 2.x --- src/Form/Type/TermsTranslationType.php | 6 + src/Resources/config/services/twig.xml | 14 + src/Resources/config/twig/twig_hooks.yaml | 14 +- src/Resources/public/slugger.js | 282 ------------------ src/Resources/public/slugify-terms-name.js | 8 - .../views/admin/terms/_form.html.twig | 2 +- .../views/admin/terms/_javascripts.html.twig | 2 - src/Twig/Component/TermsComponent.php | 49 +++ 8 files changed, 82 insertions(+), 295 deletions(-) delete mode 100644 src/Resources/public/slugger.js delete mode 100644 src/Resources/public/slugify-terms-name.js delete mode 100644 src/Resources/views/admin/terms/_javascripts.html.twig create mode 100644 src/Twig/Component/TermsComponent.php diff --git a/src/Form/Type/TermsTranslationType.php b/src/Form/Type/TermsTranslationType.php index 5a9812a..da4c90d 100644 --- a/src/Form/Type/TermsTranslationType.php +++ b/src/Form/Type/TermsTranslationType.php @@ -4,6 +4,7 @@ namespace Setono\SyliusTermsPlugin\Form\Type; +use Setono\SyliusTermsPlugin\Model\TermsTranslation; use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -17,6 +18,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->add('name', TextType::class, [ 'label' => 'setono_sylius_terms.form.terms.name', 'help' => 'setono_sylius_terms.form.terms.name_help', + 'attr' => [ + 'data-action' => 'live#action', + 'data-live-action-param' => 'on(change)|generateTermsSlug', + 'data-live-locale-code-param' => $builder->getPropertyPath()->getElement(0), + ] ]) ->add('slug', TextType::class, [ 'label' => 'setono_sylius_terms.form.terms.slug', diff --git a/src/Resources/config/services/twig.xml b/src/Resources/config/services/twig.xml index 54af49f..0b8a35e 100644 --- a/src/Resources/config/services/twig.xml +++ b/src/Resources/config/services/twig.xml @@ -14,5 +14,19 @@ + + + + + %setono_sylius_terms.model.terms.class% + Setono\SyliusTermsPlugin\Form\Type\TermsType + + + + + + + + diff --git a/src/Resources/config/twig/twig_hooks.yaml b/src/Resources/config/twig/twig_hooks.yaml index 2ecf944..f162010 100644 --- a/src/Resources/config/twig/twig_hooks.yaml +++ b/src/Resources/config/twig/twig_hooks.yaml @@ -2,7 +2,12 @@ sylius_twig_hooks: hooks: 'sylius_admin.terms.create.content': form: - template: '@SetonoSyliusTermsPlugin/admin/terms/_form.html.twig' + component: 'setono_sylius_terms:terms:form' + props: + form: '@=_context.form' + resource: '@=_context.resource' + template: '@SetonoSyliusTermsPlugin/admin/terms/_form.html.twig' + priority: 0 'sylius_admin.terms.create.content.form#left': form: template: '@SetonoSyliusTermsPlugin/admin/terms/form/left.html.twig' @@ -11,7 +16,12 @@ sylius_twig_hooks: template: '@SetonoSyliusTermsPlugin/admin/terms/form/right.html.twig' 'sylius_admin.terms.update.content': form: - template: '@SetonoSyliusTermsPlugin/admin/terms/_form.html.twig' + component: 'setono_sylius_terms:terms:form' + props: + form: '@=_context.form' + resource: '@=_context.resource' + template: '@SetonoSyliusTermsPlugin/admin/terms/_form.html.twig' + priority: 0 'sylius_admin.terms.update.content.form#left': form: template: '@SetonoSyliusTermsPlugin/admin/terms/form/left.html.twig' diff --git a/src/Resources/public/slugger.js b/src/Resources/public/slugger.js deleted file mode 100644 index a0d711a..0000000 --- a/src/Resources/public/slugger.js +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Copied from https://jsfiddle.net/ARTsinn/J4BRX/ - */ -(function () { - - // some defaults - var options = { - sensitive: false, - replacement: "-", - truncate: false - }; - - // regex - var nonWord = /\W/g, - nonAlpha = /[^a-z0-9-]/g, - whitespace = /\s+/g, - trim = /^\s+|\s+$/g; - - // replacement charmap - var map = { - "À": "A", - "Á": "A", - "Â": "A", - "Ã": "A", - "Ä": "A", - "Å": "A", - "Æ": "AE", - "Ç": "C", - "È": "E", - "É": "E", - "Ê": "E", - "Ë": "E", - "Ì": "I", - "Í": "I", - "Î": "I", - "Ï": "I", - "Ð": "D", - "Ñ": "N", - "Ò": "O", - "Ó": "O", - "Ô": "O", - "Õ": "O", - "Ö": "O", - "Ø": "O", - "Ù": "U", - "Ú": "U", - "Û": "U", - "Ü": "U", - "Ý": "Y", - "ß": "s", - "à": "a", - "á": "a", - "â": "a", - "ã": "a", - "ä": "a", - "å": "a", - "æ": "ae", - "ç": "c", - "è": "e", - "é": "e", - "ê": "e", - "ë": "e", - "ì": "i", - "í": "i", - "î": "i", - "ï": "i", - "ñ": "n", - "ò": "o", - "ó": "o", - "ô": "o", - "õ": "o", - "ö": "o", - "ø": "o", - "ù": "u", - "ú": "u", - "û": "u", - "ü": "u", - "ý": "y", - "ÿ": "y", - "Ā": "A", - "ā": "a", - "Ă": "A", - "ă": "a", - "Ą": "A", - "ą": "a", - "Ć": "C", - "ć": "c", - "Ĉ": "C", - "ĉ": "c", - "Ċ": "C", - "ċ": "c", - "Č": "C", - "č": "c", - "Ď": "D", - "ď": "d", - "Đ": "D", - "đ": "d", - "Ē": "E", - "ē": "e", - "Ĕ": "E", - "ĕ": "e", - "Ė": "E", - "ė": "e", - "Ę": "E", - "ę": "e", - "Ě": "E", - "ě": "e", - "Ĝ": "G", - "ĝ": "g", - "Ğ": "G", - "ğ": "g", - "Ġ": "G", - "ġ": "g", - "Ģ": "G", - "ģ": "g", - "Ĥ": "H", - "ĥ": "h", - "Ħ": "H", - "ħ": "h", - "Ĩ": "I", - "ĩ": "i", - "Ī": "I", - "ī": "i", - "Ĭ": "I", - "ĭ": "i", - "Į": "I", - "į": "i", - "İ": "I", - "ı": "i", - "IJ": "IJ", - "ij": "ij", - "Ĵ": "J", - "ĵ": "j", - "Ķ": "K", - "ķ": "k", - "Ĺ": "L", - "ĺ": "l", - "Ļ": "L", - "ļ": "l", - "Ľ": "L", - "ľ": "l", - "Ŀ": "L", - "ŀ": "l", - "Ł": "l", - "ł": "l", - "Ń": "N", - "ń": "n", - "Ņ": "N", - "ņ": "n", - "Ň": "N", - "ň": "n", - "ʼn": "n", - "Ō": "O", - "ō": "o", - "Ŏ": "O", - "ŏ": "o", - "Ő": "O", - "ő": "o", - "Œ": "OE", - "œ": "oe", - "Ŕ": "R", - "ŕ": "r", - "Ŗ": "R", - "ŗ": "r", - "Ř": "R", - "ř": "r", - "Ś": "S", - "ś": "s", - "Ŝ": "S", - "ŝ": "s", - "Ş": "S", - "ş": "s", - "Š": "S", - "š": "s", - "Ţ": "T", - "ţ": "t", - "Ť": "T", - "ť": "t", - "Ŧ": "T", - "ŧ": "t", - "Ũ": "U", - "ũ": "u", - "Ū": "U", - "ū": "u", - "Ŭ": "U", - "ŭ": "u", - "Ů": "U", - "ů": "u", - "Ű": "U", - "ű": "u", - "Ų": "U", - "ų": "u", - "Ŵ": "W", - "ŵ": "w", - "Ŷ": "Y", - "ŷ": "y", - "Ÿ": "Y", - "Ź": "Z", - "ź": "z", - "Ż": "Z", - "ż": "z", - "Ž": "Z", - "ž": "z", - "ſ": "s", - "ƒ": "f", - "Ơ": "O", - "ơ": "o", - "Ư": "U", - "ư": "u", - "Ǎ": "A", - "ǎ": "a", - "Ǐ": "I", - "ǐ": "i", - "Ǒ": "O", - "ǒ": "o", - "Ǔ": "U", - "ǔ": "u", - "Ǖ": "U", - "ǖ": "u", - "Ǘ": "U", - "ǘ": "u", - "Ǚ": "U", - "ǚ": "u", - "Ǜ": "U", - "ǜ": "u", - "Ǻ": "A", - "ǻ": "a", - "Ǽ": "AE", - "ǽ": "ae", - "Ǿ": "O", - "ǿ": "o" - }; - - // replacer - var mapping = function (c) { - return map[c] || c; - }; - - - /** - * Normalise a string replacing foreign characters - * whitespace and all other illegals - * @param {String} str - * @param {Object} opts - */ - - this.slugger = function (str, opts) { - if (!str || typeof str !== "string") return; - - // populate some defaults - if (opts) for (var key in opts) options[key] = opts[key]; - - // case-sensitive or not - if (!options.sensitive) str = str.toLowerCase(); - - str = str - - // trim whitespace - .replace(trim, "") - - // swap foreign characters - .replace(nonWord, mapping) - - // replace whitespace - .replace(whitespace, options.replacement) - - // remove everything but alphanumeric characters and dashes - .replace(nonAlpha, "") - - // replace multiple instances of the replacement character with a single instance - .replace(new RegExp(`[${options.replacement}]+`, 'g'), options.replacement) - ; - - // smart truncate - if (options.truncate && str.length > options.truncate) { - var cut = str.indexOf("-", options.truncate); - str = cut === -1 ? str : str.slice(0, cut); - } - - return str; - }; -}()); diff --git a/src/Resources/public/slugify-terms-name.js b/src/Resources/public/slugify-terms-name.js deleted file mode 100644 index 48bcd7d..0000000 --- a/src/Resources/public/slugify-terms-name.js +++ /dev/null @@ -1,8 +0,0 @@ -document.addEventListener('DOMContentLoaded', function (e) { - document.querySelectorAll('input[name*="setono_sylius_terms_terms[translations]"][name*="[name]"]').forEach(function (input) { - input.addEventListener('input', function (event) { - const element = event.currentTarget; - element.closest('.content').querySelector('[name*="[slug]"]').value = slugger(element.value); - }); - }); -}); diff --git a/src/Resources/views/admin/terms/_form.html.twig b/src/Resources/views/admin/terms/_form.html.twig index 4091010..a187b27 100644 --- a/src/Resources/views/admin/terms/_form.html.twig +++ b/src/Resources/views/admin/terms/_form.html.twig @@ -8,7 +8,7 @@ {% form_theme form '@SyliusAdmin/shared/form_theme.html.twig' %} -
+
{{ form_start(form, {'attr': {'novalidate': 'novalidate', 'id': form.vars.id}}) }} {% if hookable_metadata.configuration.method is defined %} diff --git a/src/Resources/views/admin/terms/_javascripts.html.twig b/src/Resources/views/admin/terms/_javascripts.html.twig deleted file mode 100644 index f650404..0000000 --- a/src/Resources/views/admin/terms/_javascripts.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': '/bundles/setonosyliustermsplugin/slugger.js'} %} -{% include '@SyliusUi/_javascripts.html.twig' with {'path': '/bundles/setonosyliustermsplugin/slugify-terms-name.js'} %} diff --git a/src/Twig/Component/TermsComponent.php b/src/Twig/Component/TermsComponent.php new file mode 100644 index 0000000..9699883 --- /dev/null +++ b/src/Twig/Component/TermsComponent.php @@ -0,0 +1,49 @@ + */ + use ResourceFormComponentTrait; + + public function __construct( + RepositoryInterface $productRepository, + FormFactoryInterface $formFactory, + string $resourceClass, + string $formClass, + protected readonly SlugGeneratorInterface $slugGenerator, + ) { + $this->initialize($productRepository, $formFactory, $resourceClass, $formClass); + } + + #[LiveAction] + public function generateTermsSlug(#[LiveArg] string $localeCode = ''): void + { + $this->formValues['translations'][$localeCode]['slug'] = $this->slugGenerator->generate($this->formValues['translations'][$localeCode]['name']); + } + + protected function getDataModelValue(): string + { + return 'norender|*'; + } +} From fe012d02d19fe5b1b11630157198a27b5d95e3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Mon, 24 Mar 2025 17:07:40 +0100 Subject: [PATCH 4/9] Add Twig hook for displaying the terms in checkout --- README.md | 32 ------------------- src/Resources/config/twig/twig_hooks.yaml | 4 +++ .../views/shop/checkout/terms.html.twig | 3 ++ 3 files changed, 7 insertions(+), 32 deletions(-) create mode 100644 src/Resources/views/shop/checkout/terms.html.twig diff --git a/README.md b/README.md index 90bce49..34b9675 100644 --- a/README.md +++ b/README.md @@ -83,38 +83,6 @@ $ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate ``` -### Step 5: Override checkout complete form - -Override the [Sylius Form](https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Complete/_form.html.twig): - -* If you haven't your own `templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig` yet: - - ```bash - $ cp vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/views/Checkout/Complete/_form.html.twig \ - templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig - ``` - -* If you already have it: - - Add terms field (exactly this conditional way): - - ```twig - {# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #} - {% if form.terms is defined %} - {{ form_row(form.terms) }} - {% endif %} - ``` - - So the final template will look like this: - - ```twig - {# templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig #} - {{ form_row(form.notes, {'attr': {'rows': 3}}) }} - {% if form.terms is defined %} - {{ form_row(form.terms) }} - {% endif %} - ``` - # Troubleshooting * If you see `Neither the property "terms" nor one of the methods "terms()", "getterms()"/"isterms()"/"hasterms()" or "__call()" exist and have public access in class "Symfony\Component\Form\FormView".` diff --git a/src/Resources/config/twig/twig_hooks.yaml b/src/Resources/config/twig/twig_hooks.yaml index f162010..3645723 100644 --- a/src/Resources/config/twig/twig_hooks.yaml +++ b/src/Resources/config/twig/twig_hooks.yaml @@ -28,3 +28,7 @@ sylius_twig_hooks: 'sylius_admin.terms.update.content.form#right': form: template: '@SetonoSyliusTermsPlugin/admin/terms/form/right.html.twig' + 'sylius_shop.checkout.complete.content.form': + terms: + template: '@SetonoSyliusTermsPlugin/shop/checkout/terms.html.twig' + priority: 50 diff --git a/src/Resources/views/shop/checkout/terms.html.twig b/src/Resources/views/shop/checkout/terms.html.twig new file mode 100644 index 0000000..7fd99c9 --- /dev/null +++ b/src/Resources/views/shop/checkout/terms.html.twig @@ -0,0 +1,3 @@ +{% if hookable_metadata.context.form.terms is defined %} + {{ form_row(hookable_metadata.context.form.terms) }} +{% endif %} From 8db4d9c7503e3b91c088fb5757f7a124f2050f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Mon, 24 Mar 2025 18:24:02 +0100 Subject: [PATCH 5/9] Fix Psalm errors --- psalm.xml | 23 ++++++++++++++++++++++- src/Form/Type/TermsTranslationType.php | 5 ++--- src/Twig/Component/TermsComponent.php | 5 ++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/psalm.xml b/psalm.xml index b3e0471..ea72749 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" - phpVersion="8.1" + phpVersion="8.2" errorLevel="1" findUnusedBaselineEntry="false" findUnusedPsalmSuppress="false" @@ -30,6 +30,11 @@ + + + + + @@ -40,5 +45,21 @@ + + + + + + + + + + + + + + + + diff --git a/src/Form/Type/TermsTranslationType.php b/src/Form/Type/TermsTranslationType.php index da4c90d..3bbb26c 100644 --- a/src/Form/Type/TermsTranslationType.php +++ b/src/Form/Type/TermsTranslationType.php @@ -4,7 +4,6 @@ namespace Setono\SyliusTermsPlugin\Form\Type; -use Setono\SyliusTermsPlugin\Model\TermsTranslation; use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -21,8 +20,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'attr' => [ 'data-action' => 'live#action', 'data-live-action-param' => 'on(change)|generateTermsSlug', - 'data-live-locale-code-param' => $builder->getPropertyPath()->getElement(0), - ] + 'data-live-locale-code-param' => $builder->getPropertyPath()?->getElement(0), + ], ]) ->add('slug', TextType::class, [ 'label' => 'setono_sylius_terms.form.terms.slug', diff --git a/src/Twig/Component/TermsComponent.php b/src/Twig/Component/TermsComponent.php index 9699883..40bd7f5 100644 --- a/src/Twig/Component/TermsComponent.php +++ b/src/Twig/Component/TermsComponent.php @@ -26,6 +26,9 @@ class TermsComponent /** @use ResourceFormComponentTrait */ use ResourceFormComponentTrait; + /** + * @param RepositoryInterface $productRepository + */ public function __construct( RepositoryInterface $productRepository, FormFactoryInterface $formFactory, @@ -39,7 +42,7 @@ public function __construct( #[LiveAction] public function generateTermsSlug(#[LiveArg] string $localeCode = ''): void { - $this->formValues['translations'][$localeCode]['slug'] = $this->slugGenerator->generate($this->formValues['translations'][$localeCode]['name']); + $this->formValues['translations'][$localeCode]['slug'] = $this->slugGenerator->generate((string) $this->formValues['translations'][$localeCode]['name']); } protected function getDataModelValue(): string From 367729f7aa4abc228ca2d5945ea728da452d79f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Mon, 24 Mar 2025 18:31:58 +0100 Subject: [PATCH 6/9] Update GitHub workflows --- .../workflows/backwards-compatibility-check.yaml | 2 +- .github/workflows/build.yaml | 14 +++++--------- composer.json | 9 ++++++--- tests/Application/config/bundles.php | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/backwards-compatibility-check.yaml b/.github/workflows/backwards-compatibility-check.yaml index 806dd6a..85ba05c 100644 --- a/.github/workflows/backwards-compatibility-check.yaml +++ b/.github/workflows/backwards-compatibility-check.yaml @@ -20,7 +20,7 @@ jobs: - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" with: - php-version: "8.1" + php-version: "8.2" coverage: "none" - name: "Install tool" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2a1e8ad..53138f0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -24,7 +24,7 @@ jobs: strategy: matrix: php-version: - - "8.1" # 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" @@ -72,7 +72,6 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.2" dependencies: @@ -80,8 +79,8 @@ jobs: - "highest" symfony: - - "~5.4.0" - "~6.4.0" + - "~7.1.0" steps: - name: "Checkout" @@ -119,7 +118,6 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.2" dependencies: @@ -127,8 +125,8 @@ jobs: - "highest" symfony: - - "~5.4.0" - "~6.4.0" + - "~7.1.0" steps: - name: "Checkout" @@ -163,7 +161,6 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.2" dependencies: @@ -171,8 +168,8 @@ jobs: - "highest" symfony: - - "~5.4.0" - "~6.4.0" + - "~7.1.0" steps: - name: "Checkout" @@ -204,7 +201,6 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.2" dependencies: @@ -212,8 +208,8 @@ jobs: - "highest" symfony: - - "~5.4.0" - "~6.4.0" + - "~7.1.0" steps: - name: "Start MySQL" diff --git a/composer.json b/composer.json index 0992f44..96eb093 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,8 @@ "sylius/core": "^2.0", "sylius/core-bundle": "^2.0", "sylius/locale": "^2.0", + "sylius/product": "^2.0", + "sylius/product-bundle": "^2.0", "sylius/resource-bundle": "^1.12", "sylius/ui-bundle": "^2.0", "symfony/config": "^6.4 || ^7.1", @@ -31,17 +33,18 @@ "symfony/routing": "^6.4 || ^7.1", "symfony/string": "^6.4 || ^7.1", "symfony/translation-contracts": "^1.1 || ^2.4 || ^3.4", + "symfony/ux-live-component": "^2.20", "symfony/validator": "^6.4 || ^7.1", "twig/twig": "^2.14 || ^3.8", "webmozart/assert": "^1.11" }, "require-dev": { - "api-platform/core": "^2.7.16", + "api-platform/core": "^2.7 || ^3.4", "babdev/pagerfanta-bundle": "^4.4", "behat/behat": "^3.14", "doctrine/doctrine-bundle": "^2.11", "infection/infection": "^0.27.9", - "jms/serializer-bundle": "^4.2", + "jms/serializer-bundle": "^5.5", "lexik/jwt-authentication-bundle": "^3.1", "matthiasnoback/symfony-config-test": "^4.3 || ^5.1", "matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0", @@ -49,7 +52,7 @@ "phpunit/phpunit": "^9.6", "psalm/plugin-phpunit": "^0.18", "setono/code-quality-pack": "^2.7", - "sylius/sylius": "~2.0", + "sylius/sylius": "^2.0", "symfony/debug-bundle": "^6.4 || ^7.1", "symfony/dotenv": "^6.4 || ^7.1", "symfony/intl": "^6.4 || ^7.1", diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 4d6ec65..b15f9af 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -31,7 +31,6 @@ Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], Setono\SyliusTermsPlugin\SetonoSyliusTermsPlugin::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], From 8830e1f2276f8032b71b40f697c97e1bea3fd68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Tue, 25 Mar 2025 11:34:10 +0100 Subject: [PATCH 7/9] Migrate test/Application to Sylius 2.x --- composer.json | 10 ++- tests/Application/.env | 38 ++++------ tests/Application/.eslintrc.js | 36 ++++----- tests/Application/.gitignore | 7 ++ 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 | 1 + tests/Application/bin/console | 2 +- tests/Application/config/bootstrap.php | 6 +- tests/Application/config/bundles.php | 29 ++++--- .../Application/config/packages/_sylius.yaml | 1 + .../config/packages/api_platform.yaml | 17 +++-- tests/Application/config/packages/assets.yaml | 4 + .../config/packages/dev/jms_serializer.yaml | 12 --- .../config/packages/doctrine_migrations.yaml | 2 + .../Application/config/packages/fos_rest.yaml | 11 --- .../config/packages/framework.yaml | 5 +- .../config/packages/http_discovery.yaml | 10 +++ .../config/packages/jms_serializer.yaml | 4 - .../config/packages/prod/jms_serializer.yaml | 10 --- .../Application/config/packages/security.yaml | 44 ++++++----- .../config/packages/setono_sylius_terms.yaml | 2 - .../sylius_state_machine_abstraction.yaml | 6 ++ .../config/packages/test/framework.yaml | 7 ++ .../config/packages/test/security.yaml | 6 -- .../config/packages/test_cached/fos_rest.yaml | 3 - .../packages/test_cached/framework.yaml | 6 +- .../config/packages/test_cached/security.yaml | 3 - .../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/setono_sylius_terms.yaml | 2 +- .../Application/config/routes/sylius_api.yaml | 2 +- .../config/routes/sylius_shop.yaml | 7 +- tests/Application/config/services_test.yaml | 8 ++ .../config/services_test_cached.yaml | 2 + tests/Application/package.json | 46 +++++------- tests/Application/src/Entity/.gitignore | 0 .../shop/terms/show/eula_us.html.twig | 20 ----- .../bundles/SyliusAdminBundle/_logo.html.twig | 5 -- .../SyliusAdminBundle/_scripts.html.twig | 1 - .../SyliusAdminBundle/_styles.html.twig | 1 - .../Checkout/Complete/_form.html.twig | 4 - .../Homepage/_banner.html.twig | 2 - .../Layout/Footer/Grid/_plus.html.twig | 9 --- .../Layout/Footer/Grid/_your_store.html.twig | 9 --- .../Layout/Header/_logo.html.twig | 5 -- .../SyliusShopBundle/_scripts.html.twig | 1 - .../SyliusShopBundle/_styles.html.twig | 1 - tests/Application/webpack.config.js | 75 ++++++++++--------- tests/Behat/Resources/services.xml | 8 ++ tests/Behat/Resources/suites.yml | 4 + 54 files changed, 231 insertions(+), 282 deletions(-) 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 delete mode 100644 tests/Application/config/packages/dev/jms_serializer.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 delete mode 100644 tests/Application/config/packages/prod/jms_serializer.yaml delete mode 100644 tests/Application/config/packages/setono_sylius_terms.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_cached/fos_rest.yaml delete mode 100644 tests/Application/config/packages/test_cached/security.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/services_test.yaml create mode 100644 tests/Application/config/services_test_cached.yaml create mode 100644 tests/Application/src/Entity/.gitignore delete mode 100644 tests/Application/templates/bundles/SetonoSyliusTermsPlugin/shop/terms/show/eula_us.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_plus.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_your_store.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig create mode 100644 tests/Behat/Resources/services.xml create mode 100644 tests/Behat/Resources/suites.yml diff --git a/composer.json b/composer.json index 96eb093..40869b0 100644 --- a/composer.json +++ b/composer.json @@ -41,8 +41,16 @@ "require-dev": { "api-platform/core": "^2.7 || ^3.4", "babdev/pagerfanta-bundle": "^4.4", - "behat/behat": "^3.14", + "behat/behat": "^3.16", "doctrine/doctrine-bundle": "^2.11", + "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", "infection/infection": "^0.27.9", "jms/serializer-bundle": "^5.5", "lexik/jwt-authentication-bundle": "^3.1", diff --git a/tests/Application/.env b/tests/Application/.env index fd5fd3d..381fb66 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -1,16 +1,5 @@ -# In all environments, the following files are loaded if they exist, -# the later taking precedence over the former: -# -# * .env contains default values for the environment variables needed by the app -# * .env.local uncommitted file with local overrides -# * .env.$APP_ENV committed environment-specific defaults -# * .env.$APP_ENV.local uncommitted environment-specific overrides -# -# Real environment variables win over .env files. -# -# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. -# -# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). +# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file +# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production. # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration ###> symfony/framework-bundle ### @@ -20,7 +9,7 @@ APP_SECRET=EDITME ###< symfony/framework-bundle ### ###> doctrine/doctrine-bundle ### -# Format described at https://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls DATABASE_URL=mysql://root@127.0.0.1/setono_sylius_terms_%kernel.environment%?serverVersion=5.7 @@ -32,16 +21,15 @@ JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem JWT_PASSPHRASE=acme_plugin_development ###< lexik/jwt-authentication-bundle ### +###> symfony/mailer ### +MAILER_DSN=null://null +###< symfony/mailer ### + ###> symfony/messenger ### -# Choose one of the transports below -# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages -MESSENGER_TRANSPORT_DSN=doctrine://default -# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages +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 ### - -###> 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_DSN=null://localhost -###< symfony/swiftmailer-bundle ### diff --git a/tests/Application/.eslintrc.js b/tests/Application/.eslintrc.js index dfddb25..92c4cee 100644 --- a/tests/Application/.eslintrc.js +++ b/tests/Application/.eslintrc.js @@ -1,20 +1,20 @@ module.exports = { - extends: 'airbnb-base', - env: { - node: true, - }, - rules: { - 'object-shorthand': ['error', 'always', { - avoidQuotes: true, - avoidExplicitReturnArrows: true, - }], - 'function-paren-newline': ['error', 'consistent'], - 'max-len': ['warn', 120, 2, { - ignoreUrls: true, - ignoreComments: false, - ignoreRegExpLiterals: true, - ignoreStrings: true, - ignoreTemplateLiterals: true, - }], - }, + extends: 'airbnb-base', + env: { + node: true, + }, + rules: { + 'object-shorthand': ['error', 'always', { + avoidQuotes: true, + avoidExplicitReturnArrows: true, + }], + 'function-paren-newline': ['error', 'consistent'], + 'max-len': ['warn', 120, 2, { + ignoreUrls: true, + ignoreComments: false, + ignoreRegExpLiterals: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + }], + }, }; diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore index bc600a8..8f00a8c 100644 --- a/tests/Application/.gitignore +++ b/tests/Application/.gitignore @@ -8,6 +8,8 @@ !/public/media/image/.gitignore /node_modules +/yarn.lock +/package-lock.json ###> symfony/framework-bundle ### /.env.*.local @@ -21,3 +23,8 @@ ###> symfony/web-server-bundle ### /.web-server-pid ###< symfony/web-server-bundle ### + +###> lexik/jwt-authentication-bundle ### +/config/jwt/*.pem +!/config/jwt/*-test.pem +###< lexik/jwt-authentication-bundle ### 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..61b4353 --- /dev/null +++ b/tests/Application/assets/shop/entrypoint.js @@ -0,0 +1 @@ +import '../../../../assets/shop/entrypoint'; diff --git a/tests/Application/bin/console b/tests/Application/bin/console index 5e2dc5f..7931172 100755 --- a/tests/Application/bin/console +++ b/tests/Application/bin/console @@ -4,7 +4,7 @@ use Setono\SyliusTermsPlugin\Tests\Application\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\ErrorHandler\Debug; +use Symfony\Component\Debug\Debug; set_time_limit(0); 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 b15f9af..7e99dc0 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -2,7 +2,7 @@ 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], @@ -31,13 +31,8 @@ Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], Setono\SyliusTermsPlugin\SetonoSyliusTermsPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::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], - League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], @@ -49,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], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => 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 a78e725..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" } diff --git a/tests/Application/config/packages/api_platform.yaml b/tests/Application/config/packages/api_platform.yaml index 26def49..ceb10e7 100644 --- a/tests/Application/config/packages/api_platform.yaml +++ b/tests/Application/config/packages/api_platform.yaml @@ -1,9 +1,10 @@ api_platform: - mapping: - paths: - - '%kernel.project_dir%/../../vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources' - - '%kernel.project_dir%/config/api_platform' - patch_formats: - json: ['application/merge-patch+json'] - swagger: - versions: [3] + 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/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 eaebb27..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/v1/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true } - - { path: '^/', stop: true } diff --git a/tests/Application/config/packages/framework.yaml b/tests/Application/config/packages/framework.yaml index 3df2c0a..9b44501 100644 --- a/tests/Application/config/packages/framework.yaml +++ b/tests/Application/config/packages/framework.yaml @@ -1,9 +1,6 @@ framework: secret: '%env(APP_SECRET)%' - ide: phpstorm - form: - enabled: true - legacy_error_messages: false + form: true csrf_protection: true session: handler_id: ~ 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/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 2f5c687..af38e75 100644 --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -1,5 +1,4 @@ security: - enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -18,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 @@ -39,26 +39,28 @@ security: path: sylius_admin_logout target: sylius_admin_login - new_api_admin_user: - pattern: "%sylius.security.new_api_admin_regex%/.*" + api_admin: + pattern: "%sylius.security.api_admin_regex%/.*" provider: sylius_api_admin_user_provider + user_checker: security.user_checker.chain.api_admin stateless: true entry_point: jwt json_login: - check_path: "%sylius.security.new_api_admin_route%/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 jwt: true - new_api_shop_user: - pattern: "%sylius.security.new_api_shop_regex%/.*" + api_shop: + pattern: "%sylius.security.api_shop_regex%/.*" provider: sylius_api_shop_user_provider + user_checker: security.user_checker.chain.api_shop stateless: true entry_point: jwt json_login: - check_path: "%sylius.security.new_api_shop_route%/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 @@ -70,6 +72,7 @@ security: 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 @@ -83,6 +86,12 @@ security: 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 @@ -93,16 +102,15 @@ security: target: sylius_shop_homepage invalidate_session: false + 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: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, 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: PUBLIC_ACCESS } @@ -114,9 +122,9 @@ security: - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } + - { 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/setono_sylius_terms.yaml b/tests/Application/config/packages/setono_sylius_terms.yaml deleted file mode 100644 index 3e571d3..0000000 --- a/tests/Application/config/packages/setono_sylius_terms.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SetonoSyliusTermsPlugin/Resources/config/app/fixtures.yaml" } 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 fc1d3c1..e71603c 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -2,3 +2,10 @@ framework: test: ~ session: 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 4071d31..0000000 --- a/tests/Application/config/packages/test/security.yaml +++ /dev/null @@ -1,6 +0,0 @@ -security: - password_hashers: - Sylius\Component\User\Model\UserInterface: - algorithm: argon2i - time_cost: 3 - memory_cost: 10 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/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/setono_sylius_terms.yaml b/tests/Application/config/routes/setono_sylius_terms.yaml index dd4189d..3cdd3b8 100644 --- a/tests/Application/config/routes/setono_sylius_terms.yaml +++ b/tests/Application/config/routes/setono_sylius_terms.yaml @@ -1,2 +1,2 @@ setono_sylius_terms: - resource: "@SetonoSyliusTermsPlugin/Resources/config/routes.yaml" + resource: "@SetonoSyliusTermsPlugin/Resources/config/routes.yaml" 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 22e7a4a..8e3dd42 100644 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -5,13 +5,16 @@ 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: diff --git a/tests/Application/config/services_test.yaml b/tests/Application/config/services_test.yaml new file mode 100644 index 0000000..d072d89 --- /dev/null +++ b/tests/Application/config/services_test.yaml @@ -0,0 +1,8 @@ +imports: + - { 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 8f62c4c..b91df2a 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,30 +1,20 @@ { - "dependencies": { - "chart.js": "^3.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/templates/bundles/SetonoSyliusTermsPlugin/shop/terms/show/eula_us.html.twig b/tests/Application/templates/bundles/SetonoSyliusTermsPlugin/shop/terms/show/eula_us.html.twig deleted file mode 100644 index 1c09e0f..0000000 --- a/tests/Application/templates/bundles/SetonoSyliusTermsPlugin/shop/terms/show/eula_us.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends '@SyliusShop/layout.html.twig' %} - -{%- block title -%} - {{ terms.name }} -{%- endblock -%} - -{% block content %} - {% include '@SetonoSyliusTermsPlugin/shop/terms/show/_breadcrumb.html.twig' %} - - - -
-
-

NOTICE: This is a special template only for the EULA US terms

-

{{ terms.name }}

- - {{ terms.content|raw }} -
-
-{% endblock %} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig deleted file mode 100644 index 1b65d7f..0000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - -
- Sylius -
-
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig deleted file mode 100644 index f5f9835..0000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_script_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig deleted file mode 100644 index a96144c..0000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_link_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig deleted file mode 100644 index f4bd66e..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Checkout/Complete/_form.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{{ form_row(form.notes, {'attr': {'rows': 3}}) }} -{% if form.terms is defined %} - {{ form_row(form.terms) }} -{% endif %} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig deleted file mode 100644 index bb594f7..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -Sylius - diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_plus.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_plus.html.twig deleted file mode 100644 index 0bf5a06..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_plus.html.twig +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_your_store.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_your_store.html.twig deleted file mode 100644 index b65f2c1..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_your_store.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -
-

{{ 'sylius.ui.your_store'|trans }}

- -
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig deleted file mode 100644 index 39110d6..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig deleted file mode 100644 index d1655bb..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_script_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig deleted file mode 100644 index fd2c7cb..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_link_tags('shop-entry', null, 'shop') }} 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]; diff --git a/tests/Behat/Resources/services.xml b/tests/Behat/Resources/services.xml new file mode 100644 index 0000000..8996f62 --- /dev/null +++ b/tests/Behat/Resources/services.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml new file mode 100644 index 0000000..4a055e7 --- /dev/null +++ b/tests/Behat/Resources/suites.yml @@ -0,0 +1,4 @@ +# Put your Behat suites definitions here + +default: + suites: From cb35a8df3e193a10f823bba77a153e4c8702344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Sat, 28 Jun 2025 09:05:17 +0200 Subject: [PATCH 8/9] Fix CI pipeline errors --- composer.json | 3 +- tests/Application/.env.test | 13 +++- tests/Application/.gitignore | 7 --- tests/Application/Kernel.php | 62 +------------------ tests/Application/assets/shop/entrypoint.js | 1 - tests/Application/bin/console | 4 +- tests/Application/config/routes.yaml | 3 + tests/Application/public/index.php | 2 +- .../Application/public/media/image/.gitignore | 0 .../bundles/SyliusAdminBundle/_logo.html.twig | 5 ++ .../SyliusAdminBundle/_scripts.html.twig | 1 + .../SyliusAdminBundle/_styles.html.twig | 1 + .../Layout/Header/_header.html.twig | 5 ++ .../SyliusShopBundle/_scripts.html.twig | 1 + .../SyliusShopBundle/_styles.html.twig | 1 + 15 files changed, 35 insertions(+), 74 deletions(-) create mode 100644 tests/Application/public/media/image/.gitignore create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_header.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig diff --git a/composer.json b/composer.json index 40869b0..af0c4c3 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "webmozart/assert": "^1.11" }, "require-dev": { - "api-platform/core": "^2.7 || ^3.4", + "api-platform/core": "^4.0.3", "babdev/pagerfanta-bundle": "^4.4", "behat/behat": "^3.16", "doctrine/doctrine-bundle": "^2.11", @@ -56,6 +56,7 @@ "lexik/jwt-authentication-bundle": "^3.1", "matthiasnoback/symfony-config-test": "^4.3 || ^5.1", "matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0", + "payum/core": "^1.7.4", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6", "psalm/plugin-phpunit": "^0.18", diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 2d53b11..322e373 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -1,2 +1,13 @@ APP_SECRET='ch4mb3r0f5ecr3ts' -KERNEL_CLASS='Setono\SyliusTermsPlugin\Tests\Application\Kernel' + +KERNEL_CLASS='Tests\Setono\SyliusTermsPlugin\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/.gitignore b/tests/Application/.gitignore index 8f00a8c..bc600a8 100644 --- a/tests/Application/.gitignore +++ b/tests/Application/.gitignore @@ -8,8 +8,6 @@ !/public/media/image/.gitignore /node_modules -/yarn.lock -/package-lock.json ###> symfony/framework-bundle ### /.env.*.local @@ -23,8 +21,3 @@ ###> symfony/web-server-bundle ### /.web-server-pid ###< symfony/web-server-bundle ### - -###> lexik/jwt-authentication-bundle ### -/config/jwt/*.pem -!/config/jwt/*-test.pem -###< lexik/jwt-authentication-bundle ### diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 374aaf0..df15d5a 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -2,72 +2,12 @@ declare(strict_types=1); -namespace Setono\SyliusTermsPlugin\Tests\Application; +namespace Tests\Setono\SyliusTermsPlugin\Application; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; 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) { - $bundlesFile = $confDir . '/bundles.php'; - if (false === is_file($bundlesFile)) { - continue; - } - yield from $this->registerBundlesFromFile($bundlesFile); - } - } - - protected function configureRoutes(RoutingConfigurator $routes): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadRoutesConfiguration($routes, $confDir); - } - } - - private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void - { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); - } - - /** - * @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/shop/entrypoint.js b/tests/Application/assets/shop/entrypoint.js index 61b4353..e69de29 100644 --- a/tests/Application/assets/shop/entrypoint.js +++ b/tests/Application/assets/shop/entrypoint.js @@ -1 +0,0 @@ -import '../../../../assets/shop/entrypoint'; diff --git a/tests/Application/bin/console b/tests/Application/bin/console index 7931172..ec913d3 100755 --- a/tests/Application/bin/console +++ b/tests/Application/bin/console @@ -1,10 +1,10 @@ #!/usr/bin/env php +
+ +
+ diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig new file mode 100644 index 0000000..f5f9835 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig new file mode 100644 index 0000000..a96144c --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_header.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_header.html.twig new file mode 100644 index 0000000..915d0a8 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_header.html.twig @@ -0,0 +1,5 @@ + diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig new file mode 100644 index 0000000..d1655bb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig new file mode 100644 index 0000000..fd2c7cb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('shop-entry', null, 'shop') }} From 8a497d6fde4c64eaa358ca4f27b81ff32a8f285f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Tue, 21 Oct 2025 20:58:30 +0200 Subject: [PATCH 9/9] Allow doctrine ^3.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index af0c4c3..d8cc539 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": ">=8.2", "doctrine/collections": "^2.2", - "doctrine/orm": "^2.7", + "doctrine/orm": "^2.7 || ^3.0", "fakerphp/faker": "^1.23", "knplabs/knp-menu": "^3.1", "sylius/channel": "^2.0",