diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3797c1c..4e90485 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,18 +20,11 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.0", "8.1", "8.2", "8.3" ] - symfony: [ "^5.4", "^6.4" ] - sylius: [ "~1.12.0", "~1.13.0" ] - node: [ "18.x", "20.x" ] + php: [ "8.2", "8.3" ] + symfony: [ "^7.1" ] + sylius: [ "^2.0" ] + node: [ "20.x" ] mysql: [ "8.0" ] - - exclude: - - sylius: "~1.13.0" - php: "8.0" - - sylius: "~1.12.0" - php: "8.0" - symfony: "^6.4" env: APP_ENV: test @@ -189,7 +182,7 @@ jobs: - name: Upload Behat logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: Behat logs diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml index 144689b..4076ba2 100644 --- a/.github/workflows/coding_standard.yml +++ b/.github/workflows/coding_standard.yml @@ -18,18 +18,10 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.0", "8.1", "8.2", "8.3" ] - symfony: [ "^5.4", "^6.4" ] - sylius: [ "^1.12", "^1.13" ] - node: [ "18.x", "20.x" ] - mysql: [ "8.0" ] - - exclude: - - sylius: ^1.13 - php: 8.0 - - sylius: ^1.12 - php: 8.0 - symfony: ^6.4 + php: [ "8.2", "8.3" ] + symfony: [ "^7.1" ] + sylius: [ "^2.0" ] + node: [ "20.x" ] steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index 6772c7d..86f77da 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ tests/Application/web/* /etc/build/* !/etc/build/.gitkeep +.idea +package-lock.json diff --git a/composer.json b/composer.json index f515302..db65743 100644 --- a/composer.json +++ b/composer.json @@ -5,48 +5,52 @@ "description": "CrossSelling plugin for Sylius applications.", "license": "MIT", "require": { - "php": "^8.0", - "friendsofsymfony/elastica-bundle": "^6.0", - "sylius/sylius": "~1.12.0 || ~1.13.0", - "symfony/webpack-encore-bundle": "^1.16" + "php": "~8.2.0 || ~8.3.0", + "friendsofsymfony/elastica-bundle": "^6.4", + "sylius/sylius": "^2.0.0", + "sylius/twig-hooks": "^0.6", + "sylius/twig-extra": "^0.6", + "symfony/ux-autocomplete": "^2.17", + "symfony/ux-live-component": "^2.20", + "symfony/ux-twig-component": "^2.20", + "symfony/webpack-encore-bundle": "^2.1", + "symfony/stimulus-bundle": "^2.12" }, "require-dev": { - "behat/behat": "^3.7", - "behat/mink-selenium2-driver": "^1.4", + "behat/behat": "^3.14", + "behat/mink-selenium2-driver": "1.6.0", "bitbag/coding-standard": "^3.0", - "dmore/behat-chrome-extension": "^1.3", - "dmore/chrome-mink-driver": "^2.7", - "friends-of-behat/mink": "^1.8", - "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-debug-extension": "^2.0", - "friends-of-behat/mink-extension": "^2.4", + "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.0", - "friends-of-behat/symfony-extension": "^2.1", - "friends-of-behat/variadic-extension": "^1.3", - "lchrusciel/api-test-case": "^5.0", + "friends-of-behat/symfony-extension": "^2.6", + "friends-of-behat/variadic-extension": "^1.6", + "lchrusciel/api-test-case": "^5.3", "phpspec/phpspec": "^7.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.8.1", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^1.12", "phpstan/phpstan-doctrine": "^1.3", - "phpstan/phpstan-strict-rules": "^1.3.0", - "phpstan/phpstan-webmozart-assert": "^1.2.0", - "phpunit/phpunit": "^9.5", + "phpstan/phpstan-strict-rules": "^1.6.0", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^10.5", "sylius-labs/coding-standard": "^4.0", - "symfony/browser-kit": "^5.4 || ^6.0", - "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/browser-kit": "^7.1", + "symfony/debug-bundle": "^7.1", + "symfony/dotenv": "^7.1", + "symfony/intl": "^7.1", + "symfony/web-profiler-bundle": "^7.1", "polishsymfonycommunity/symfony-mocker-container": "^1.0" }, - "conflict": { - "behat/mink-selenium2-driver": ">=1.7.0" - }, "config": { "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": false, + "php-http/discovery": true, "phpstan/extension-installer": false, "symfony/thanks": false } diff --git a/doc/01.1-webpack-config.md b/doc/01.1-webpack-config.md index dc7c435..dd148d0 100644 --- a/doc/01.1-webpack-config.md +++ b/doc/01.1-webpack-config.md @@ -49,19 +49,17 @@ webpack_encore: 4. Add encore functions to your templates ```twig -{# @SyliusShopBundle/_scripts.html.twig #} -{{ encore_entry_script_tags('bitbag-cs-shop', null, 'cs_shop') }} - -{# @SyliusShopBundle/_styles.html.twig #} -{{ encore_entry_link_tags('bitbag-cs-shop', null, 'cs_shop') }} - -{# @SyliusAdminBundle/_scripts.html.twig #} +{# templates/admin/javascripts.html.twig #} {{ encore_entry_script_tags('bitbag-cs-admin', null, 'cs_admin') }} -{# @SyliusAdminBundle/_styles.html.twig #} +{# templates/admin/stylesheets.html.twig #} {{ encore_entry_link_tags('bitbag-cs-admin', null, 'cs_admin') }} -``` -Please note, the template file paths may differ, depending on Sylius version. +{# templates/shop/javascripts.html.twig #} +{{ encore_entry_script_tags('bitbag-cs-shop', null, 'cs_shop') }} + +{# templates/shop/stylesheets.html.twig #} +{{ encore_entry_link_tags('bitbag-cs-shop', null, 'cs_shop') }} +``` 5. Run `yarn encore dev` or `yarn encore production` diff --git a/doc/installation.md b/doc/installation.md index 208b0e5..09ed72f 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -16,13 +16,13 @@ ADDITIONAL ## Requirements: We work on stable, supported and up-to-date versions of packages. We recommend you to do the same. -| Package | Version | -|---------------|-----------------| -| PHP | \>=8.0 | -| sylius/sylius | 1.12.x - 1.13.x | -| MySQL | \>= 5.7 | -| NodeJS | \>= 18.x | -| ElasticSearch | \>= 7.x | +| Package | Version | +|---------------|----------| +| PHP | \>=8.2 | +| sylius/sylius | \>=2.0.0 | +| MySQL | \>= 5.7 | +| NodeJS | \>= 20.x | +| ElasticSearch | \>= 7.x | ## Composer: ```bash @@ -130,18 +130,18 @@ Add encore functions to your templates: SyliusAdminBundle: ```php -{# @SyliusAdminBundle/_scripts.html.twig #} +{# templates/admin/javascripts.html.twig #} {{ encore_entry_script_tags('bitbag-cs-admin', null, 'cs_admin') }} -{# @SyliusAdminBundle/_styles.html.twig #} +{# templates/admin/stylesheets.html.twig #} {{ encore_entry_link_tags('bitbag-cs-admin', null, 'cs_admin') }} ``` SyliusShopBundle: ```php -{# @SyliusShopBundle/_scripts.html.twig #} +{# templates/shop/javascripts.html.twig #} {{ encore_entry_script_tags('bitbag-cs-shop', null, 'cs_shop') }} -{# @SyliusShopBundle/_styles.html.twig #} +{# templates/shop/stylesheets.html.twig #} {{ encore_entry_link_tags('bitbag-cs-shop', null, 'cs_shop') }} ``` diff --git a/src/Resources/config/config.yaml b/src/Resources/config/config.yaml index 2dc3103..804214d 100644 --- a/src/Resources/config/config.yaml +++ b/src/Resources/config/config.yaml @@ -1,3 +1,3 @@ imports: - { resource: "@BitBagSyliusCrossSellingPlugin/Resources/config/indexes/*" } - - { resource: "@BitBagSyliusCrossSellingPlugin/Resources/config/ui.yaml" } + - { resource: "@BitBagSyliusCrossSellingPlugin/Resources/config/twig_hooks.yaml" } diff --git a/src/Resources/config/services/twig.xml b/src/Resources/config/services/twig.xml index 00e863e..c59aedd 100644 --- a/src/Resources/config/services/twig.xml +++ b/src/Resources/config/services/twig.xml @@ -6,7 +6,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" > - @SyliusShop/Product/_horizontalList.html.twig + @SyliusShop/shared/product/horizontal_list.html.twig diff --git a/src/Resources/config/twig_hooks.yaml b/src/Resources/config/twig_hooks.yaml new file mode 100644 index 0000000..93355db --- /dev/null +++ b/src/Resources/config/twig_hooks.yaml @@ -0,0 +1,9 @@ +sylius_twig_hooks: + hooks: + 'sylius_shop.product.show.content.product_listing': + related_products: + template: "@BitBagSyliusCrossSellingPlugin/Shop/Product/_relatedProducts.html.twig" + priority: 15 + associations: + template: '@SyliusShop/product/show/content/product_listing/associations.html.twig' + priority: 0 diff --git a/src/Resources/config/ui.yaml b/src/Resources/config/ui.yaml deleted file mode 100644 index 46ebf62..0000000 --- a/src/Resources/config/ui.yaml +++ /dev/null @@ -1,7 +0,0 @@ -sylius_ui: - events: - sylius.shop.product.show.content: - blocks: - related_products: - template: "@BitBagSyliusCrossSellingPlugin/Shop/Product/_relatedProducts.html.twig" - priority: 15 diff --git a/src/Resources/views/Shop/Product/_relatedProducts.html.twig b/src/Resources/views/Shop/Product/_relatedProducts.html.twig index 7f0d1a8..c473ef1 100644 --- a/src/Resources/views/Shop/Product/_relatedProducts.html.twig +++ b/src/Resources/views/Shop/Product/_relatedProducts.html.twig @@ -1,7 +1,13 @@ -

- {{ 'bitbag_sylius_crossselling_plugin.ui.related_products'|trans }} -

-{{ bitbag_crossselling_render_related_products(product.slug, 4) }} +{% set product = hookable_metadata.context.product %} + +
+

+ {{ 'bitbag_sylius_crossselling_plugin.ui.related_products'|trans }} +

+
+ {{ bitbag_crossselling_render_related_products(product.slug, 4) }} +
+
diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 6efc452..599d8d5 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -5,7 +5,6 @@ namespace Tests\BitBag\SyliusCrossSellingPlugin\Application; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; -use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Resource\FileResource; @@ -13,7 +12,6 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -use Symfony\Component\Routing\RouteCollectionBuilder; final class Kernel extends BaseKernel { @@ -114,13 +112,5 @@ private function registerBundlesFromFile(string $bundlesFile): iterable private function getConfigurationDirectories(): iterable { yield $this->getProjectDir() . '/config'; - $syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; - if (is_dir($syliusConfigDir)) { - yield $syliusConfigDir; - } - $symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . '.' . BaseKernel::MINOR_VERSION; - if (is_dir($symfonyConfigDir)) { - yield $symfonyConfigDir; - } } } diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js index 635f5ac..063df3e 100644 --- a/tests/Application/assets/admin/entry.js +++ b/tests/Application/assets/admin/entry.js @@ -1 +1 @@ -import 'sylius/bundle/AdminBundle/Resources/private/entry'; +import 'sylius/bundle/AdminBundle/Resources/assets/entrypoint'; diff --git a/tests/Application/assets/admin/product-entry.js b/tests/Application/assets/admin/product-entry.js new file mode 100644 index 0000000..eda4835 --- /dev/null +++ b/tests/Application/assets/admin/product-entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/AdminBundle/Resources/assets/scripts/product/attribute-tabs-refresher'; diff --git a/tests/Application/assets/controllers.json b/tests/Application/assets/controllers.json new file mode 100644 index 0000000..8428b1f --- /dev/null +++ b/tests/Application/assets/controllers.json @@ -0,0 +1,17 @@ +{ + "controllers": { + "@symfony/ux-autocomplete": { + "autocomplete": { + "main": "dist/controller.js", + "webpackMode": "eager", + "fetch": "eager", + "enabled": true, + "autoimport": { + "tom-select/dist/css/tom-select.default.css": false, + "tom-select/dist/css/tom-select.bootstrap5.css": false + } + } + } + }, + "entrypoints": [] +} diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js index aadc317..dbb7d93 100644 --- a/tests/Application/assets/shop/entry.js +++ b/tests/Application/assets/shop/entry.js @@ -1 +1 @@ -import 'sylius/bundle/ShopBundle/Resources/private/entry'; +import 'sylius/bundle/ShopBundle/Resources/assets/entrypoint'; diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index 2291ab4..450a654 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -1,5 +1,12 @@ ['all' => true], Sylius\Bundle\ResourceBundle\SyliusResourceBundle::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], - Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], +// Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], - Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], +// Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], @@ -51,14 +53,20 @@ Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], FOS\ElasticaBundle\FOSElasticaBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], League\FlysystemBundle\FlysystemBundle::class =>['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], + Sylius\TwigHooks\SyliusTwigHooksBundle::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], + Symfony\UX\Icons\UXIconsBundle::class => ['all' => true], + Sylius\TwigExtra\Symfony\SyliusTwigExtraBundle::class => ['all' => true], ]; 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..8be5f3d --- /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/sylius/1.12/packages/security.yaml b/tests/Application/config/packages/security.yaml similarity index 72% rename from tests/Application/config/sylius/1.12/packages/security.yaml rename to tests/Application/config/packages/security.yaml index 71d89cd..de77116 100644 --- a/tests/Application/config/sylius/1.12/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/test_cached/doctrine.yaml b/tests/Application/config/packages/test_cached/doctrine.yaml deleted file mode 100644 index 4952860..0000000 --- a/tests/Application/config/packages/test_cached/doctrine.yaml +++ /dev/null @@ -1,16 +0,0 @@ -doctrine: - orm: - entity_managers: - default: - result_cache_driver: - type: memcached - host: localhost - port: 11211 - query_cache_driver: - type: memcached - host: localhost - port: 11211 - metadata_cache_driver: - type: memcached - host: localhost - port: 11211 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/validator.yaml b/tests/Application/config/packages/validator.yaml index 61807db..8ff7da1 100644 --- a/tests/Application/config/packages/validator.yaml +++ b/tests/Application/config/packages/validator.yaml @@ -1,3 +1,3 @@ framework: validation: - enable_annotations: true + enable_attributes: true diff --git a/tests/Application/config/routes/sylius_admin.yaml b/tests/Application/config/routes/sylius_admin.yaml index 1ba48d6..c76c433 100644 --- a/tests/Application/config/routes/sylius_admin.yaml +++ b/tests/Application/config/routes/sylius_admin.yaml @@ -1,3 +1,7 @@ sylius_admin: resource: "@SyliusAdminBundle/Resources/config/routing.yml" prefix: /admin + +live_component: + resource: "@LiveComponentBundle/config/routes.php" + prefix: /_components 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..dfee64e 100644 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -4,11 +4,15 @@ sylius_shop: requirements: _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" +#sylius_shop_payum: +# resource: "@SyliusShopBundle/Resources/config/routing/payum.yml" sylius_shop_default_locale: path: / methods: [GET] defaults: - _controller: sylius.controller.shop.locale_switch:switchAction + _controller: sylius.controller.shop.locale_switch::switchAction + +live_component: + resource: "@LiveComponentBundle/config/routes.php" + prefix: /_components diff --git a/tests/Application/config/routes/ux.yaml b/tests/Application/config/routes/ux.yaml new file mode 100644 index 0000000..2a77f55 --- /dev/null +++ b/tests/Application/config/routes/ux.yaml @@ -0,0 +1,3 @@ +live_component: + resource: "@LiveComponentBundle/config/routes.php" + prefix: /_components diff --git a/tests/Application/config/sylius/1.13/bundles.php b/tests/Application/config/sylius/1.13/bundles.php deleted file mode 100644 index 5d54121..0000000 --- a/tests/Application/config/sylius/1.13/bundles.php +++ /dev/null @@ -1,7 +0,0 @@ - ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.13/packages/security.yaml b/tests/Application/config/sylius/1.13/packages/security.yaml deleted file mode 100644 index 6745ae8..0000000 --- a/tests/Application/config/sylius/1.13/packages/security.yaml +++ /dev/null @@ -1,124 +0,0 @@ -security: - enable_authenticator_manager: true - providers: - sylius_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_api_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - sylius_api_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - - password_hashers: - Sylius\Component\User\Model\UserInterface: argon2i - firewalls: - admin: - switch_user: true - context: admin - pattern: "%sylius.security.admin_regex%" - provider: sylius_admin_user_provider - form_login: - provider: sylius_admin_user_provider - login_path: sylius_admin_login - check_path: sylius_admin_login_check - failure_path: sylius_admin_login - default_target_path: sylius_admin_dashboard - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_admin_security_token - csrf_token_id: admin_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - 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 - - new_api_admin_user: - pattern: "%sylius.security.new_api_admin_regex%/.*" - provider: sylius_api_admin_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_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%/.*" - provider: sylius_api_shop_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_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 - jwt: true - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_homepage - invalidate_session: false - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - image_resolver: - pattern: ^/media/cache/resolve - 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%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - - { 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.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_route%/administrators/reset-password", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/administrators/token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/customers/token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } \ No newline at end of file diff --git a/tests/Application/package.json b/tests/Application/package.json index f188aaa..d2c18b7 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,7 +1,13 @@ { "dependencies": { "@babel/polyfill": "^7.0.0", + "@popperjs/core": "^2.11.8", + "@tabler/core": "^1.0.0-beta21", + "apexcharts": "^3.53.0", + "bootstrap": "^5.3.3", "chart.js": "^3.7.1", + "flag-icons": "^7.2.3", + "infinite-tree": "^1.18.0", "jquery": "^3.5.0", "jquery.dirtyforms": "^2.0.0", "lightbox2": "^2.9.0", @@ -9,6 +15,10 @@ "slick-carousel": "^1.8.1" }, "devDependencies": { + "@hotwired/stimulus": "^3.2.2", + "@symfony/stimulus-bridge": "^3.2.2", + "@symfony/ux-autocomplete": "file:../../vendor/symfony/ux-autocomplete/assets", + "@symfony/ux-live-component": "file:../../vendor/symfony/ux-live-component/assets", "@symfony/webpack-encore": "^1.6.1", "babel-core": "^6.26.3", "babel-plugin-external-helpers": "^6.22.0", @@ -23,7 +33,10 @@ "eslint-plugin-import": "^2.11.0", "merge-stream": "^1.0.0", "sass": "^1.39.2", - "sass-loader": "^12.1.0" + "sass-loader": "^12.1.0", + "slugify": "^1.6.6", + "stimulus-use": "^0.52.2", + "tom-select": "^2.3.1" }, "scripts": { "dev": "yarn encore dev", @@ -38,4 +51,4 @@ }, "author": "Paweł Jędrzejewski", "license": "MIT" -} \ No newline at end of file +} diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/public/media/image/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig b/tests/Application/templates/admin/javascripts.html.twig similarity index 100% rename from tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig rename to tests/Application/templates/admin/javascripts.html.twig diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig b/tests/Application/templates/admin/stylesheets.html.twig similarity index 100% rename from tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig rename to tests/Application/templates/admin/stylesheets.html.twig 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 @@ -
- -

- Need even more features? -
Check Sylius Plus out!
-

- Sylius Plus -
-
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig b/tests/Application/templates/shop/homepage/banner.html.twig similarity index 100% rename from tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig rename to tests/Application/templates/shop/homepage/banner.html.twig diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/shop/javascripts.html.twig similarity index 100% rename from tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig rename to tests/Application/templates/shop/javascripts.html.twig diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/shop/stylesheets.html.twig similarity index 100% rename from tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig rename to tests/Application/templates/shop/stylesheets.html.twig diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index be0fe91..fb42fdc 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -10,6 +10,7 @@ const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/privat Encore.setOutputPath('public/build/shop/') .setPublicPath('/build/shop') .addEntry('shop-entry', './assets/shop/entry.js') + .enableStimulusBridge('./assets/controllers.json') .disableSingleRuntimeChunk() .cleanupOutputBeforeBuild() .enableSourceMaps(!Encore.isProduction()) @@ -29,6 +30,8 @@ Encore.reset(); Encore.setOutputPath('public/build/admin/') .setPublicPath('/build/admin') .addEntry('admin-entry', './assets/admin/entry.js') + .addEntry('admin-product-entry', './assets/admin/product-entry.js') + .enableStimulusBridge('./assets/controllers.json') .disableSingleRuntimeChunk() .cleanupOutputBeforeBuild() .enableSourceMaps(!Encore.isProduction()) diff --git a/tests/Behat/Context/Setup/RelatedProductsContext.php b/tests/Behat/Context/Setup/RelatedProductsContext.php index 8fa07b6..4131a70 100644 --- a/tests/Behat/Context/Setup/RelatedProductsContext.php +++ b/tests/Behat/Context/Setup/RelatedProductsContext.php @@ -12,9 +12,9 @@ use Behat\Behat\Context\Context; use Doctrine\ORM\EntityManagerInterface; -use SM\Factory\FactoryInterface as StateMachineFactoryInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Model\OrderInterface; +use Sylius\Component\Core\OrderPaymentStates; use Sylius\Component\Core\Model\OrderItemInterface; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Model\ProductVariantInterface; @@ -25,47 +25,22 @@ use Sylius\Component\Order\OrderTransitions; use Sylius\Component\Payment\PaymentTransitions; use Sylius\Component\Resource\Factory\FactoryInterface; +use Symfony\Component\Workflow\WorkflowInterface; use Webmozart\Assert\Assert; final class RelatedProductsContext implements Context { - /** @var SharedStorageInterface */ - private $sharedStorage; - - /** @var FactoryInterface */ - private $orderFactory; - - /** @var FactoryInterface */ - private $orderItemFactory; - - /** @var FactoryInterface */ - private $customerFactory; - - /** @var StateMachineFactoryInterface */ - private $stateMachineFactory; - - /** @var OrderItemQuantityModifierInterface */ - private $itemQuantityModifier; - - /** @var EntityManagerInterface */ - private $entityManager; - public function __construct( - SharedStorageInterface $sharedStorage, - FactoryInterface $orderFactory, - FactoryInterface $orderItemFactory, - FactoryInterface $customerFactory, - StateMachineFactoryInterface $stateMachineFactory, - OrderItemQuantityModifierInterface $itemQuantityModifier, - EntityManagerInterface $entityManager + private readonly SharedStorageInterface $sharedStorage, + private readonly FactoryInterface $orderFactory, + private readonly FactoryInterface $orderItemFactory, + private readonly FactoryInterface $customerFactory, + private readonly WorkflowInterface $orderWorkflow, + private readonly WorkflowInterface $orderPaymentWorkflow, + private readonly WorkflowInterface $shipmentWorkflow, + private readonly OrderItemQuantityModifierInterface $itemQuantityModifier, + private readonly EntityManagerInterface $entityManager ) { - $this->sharedStorage = $sharedStorage; - $this->orderFactory = $orderFactory; - $this->orderItemFactory = $orderItemFactory; - $this->customerFactory = $customerFactory; - $this->stateMachineFactory = $stateMachineFactory; - $this->itemQuantityModifier = $itemQuantityModifier; - $this->entityManager = $entityManager; } /** @@ -90,8 +65,8 @@ private function createOrdersWithProducts( Assert::greaterThanEq($numberOfOrders, 1); for ($i = 0; $i < $numberOfOrders; ++$i) { $order = $this->createOrder(); - $this->stateMachineFactory->get($order, OrderTransitions::GRAPH) - ->apply(OrderTransitions::TRANSITION_CREATE); + + $this->orderWorkflow->apply($order, OrderTransitions::TRANSITION_CREATE); $this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE); foreach ($products as $product) { @@ -145,8 +120,7 @@ private function createCustomer(): CustomerInterface private function applyPaymentTransitionOnOrder(OrderInterface $order, string $transition) { foreach ($order->getPayments() as $payment) { - $this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH) - ->apply($transition); + $this->orderWorkflow->apply($payment, $transition); } } @@ -163,13 +137,11 @@ private function addVariantWithPriceToOrder(OrderInterface $order, ProductVarian private function payOrder(OrderInterface $order): void { - $this->stateMachineFactory->get($order, OrderPaymentTransitions::GRAPH) - ->apply(OrderPaymentTransitions::TRANSITION_PAY); + $this->orderPaymentWorkflow->apply($order,OrderPaymentTransitions::TRANSITION_PAY); } private function shipOrder(OrderInterface $order): void { - $this->stateMachineFactory->get($order, OrderShippingTransitions::GRAPH) - ->apply(OrderShippingTransitions::TRANSITION_SHIP); + $this->shipmentWorkflow->apply($order,OrderShippingTransitions::TRANSITION_SHIP); } } diff --git a/tests/Behat/Resources/services/contexts/setup.xml b/tests/Behat/Resources/services/contexts/setup.xml index dffe61d..9db6ce6 100644 --- a/tests/Behat/Resources/services/contexts/setup.xml +++ b/tests/Behat/Resources/services/contexts/setup.xml @@ -16,8 +16,10 @@ - - + + + +