Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade plugin to Sylius 2.0 #53

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [ "^6.4", "^7.1" ]
sylius: [ "~v2.0.0-alpha.2" ]
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
Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/coding_standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [ "^6.4", "^7.1" ]
sylius: [ "~v2.0.0-alpha.2" ]
node: [ "20.x" ]

steps:
- uses: actions/checkout@v3
Expand Down
26 changes: 17 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
"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",
"friendsofsymfony/elastica-bundle": "^6.4",
"sylius/grid-bundle": "^1.13@alpha",
"sylius/resource": "v1.12.x-dev",
"sylius/resource-bundle": "1.12.x-dev",
"sylius/sylius": "~v2.0.0-alpha.2",
"sylius/twig-hooks": "^0.3.0",
"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",
Expand All @@ -33,11 +41,11 @@
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.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": "^6.4 || ^7.1",
"symfony/debug-bundle": "^6.4 || ^7.1",
"symfony/dotenv": "^6.4 || ^7.1",
"symfony/intl": "^6.4 || ^7.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.1",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
"conflict": {
Expand Down
14 changes: 7 additions & 7 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
imports:
- { resource: "@BitBagSyliusCrossSellingPlugin/Resources/config/indexes/*" }
- { resource: "@BitBagSyliusCrossSellingPlugin/Resources/config/ui.yaml" }
- { resource: "@BitBagSyliusCrossSellingPlugin/Resources/config/twig_hooks.yaml" }
2 changes: 1 addition & 1 deletion src/Resources/config/services/twig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<parameters>
<parameter key="bitbag_sylius_crossselling_plugin.template.related_products" type="string">@SyliusShop/Product/_horizontalList.html.twig</parameter>
<parameter key="bitbag_sylius_crossselling_plugin.template.related_products" type="string">@SyliusShop/shared/product/horizontal_list.html.twig</parameter>
</parameters>

<services>
Expand Down
9 changes: 9 additions & 0 deletions src/Resources/config/twig_hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
twig_hooks:
hooks:
'sylius_shop.product.show.page.product_listing':
related_products:
template: "@BitBagSyliusCrossSellingPlugin/Shop/Product/_relatedProducts.html.twig"
priority: 15
associations:
template: "@SyliusShop/product/show/page/product_listing/associations.html.twig"
priority: 10
7 changes: 0 additions & 7 deletions src/Resources/config/ui.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions src/Resources/views/Shop/Product/_relatedProducts.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<h4
{% set product = hookable_metadata.context.product %}
<h2
class="ui horizontal section divider header"
{{ sylius_test_html_attribute('related-products-header') }}
>
{{ 'bitbag_sylius_crossselling_plugin.ui.related_products'|trans }}
</h4>
</h2>
{{ bitbag_crossselling_render_related_products(product.slug, 4) }}
8 changes: 1 addition & 7 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
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;
use Symfony\Component\DependencyInjection\ContainerBuilder;
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
{
Expand Down Expand Up @@ -114,11 +112,7 @@ 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;
$symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . 'x';
if (is_dir($symfonyConfigDir)) {
yield $symfonyConfigDir;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/assets/admin/entry.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'sylius/bundle/AdminBundle/Resources/private/entry';
import 'sylius/bundle/AdminBundle/Resources/assets/entrypoint';
1 change: 1 addition & 0 deletions tests/Application/assets/admin/product-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'sylius/bundle/AdminBundle/Resources/assets/scripts/product/attribute-tabs-refresher';
17 changes: 17 additions & 0 deletions tests/Application/assets/controllers.json
Original file line number Diff line number Diff line change
@@ -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": []
}
2 changes: 1 addition & 1 deletion tests/Application/assets/shop/entry.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'sylius/bundle/ShopBundle/Resources/private/entry';
import 'sylius/bundle/ShopBundle/Resources/assets/entrypoint';
7 changes: 7 additions & 0 deletions tests/Application/config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

use Symfony\Component\Dotenv\Dotenv;
Expand Down
18 changes: 14 additions & 4 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

return [
Expand Down Expand Up @@ -32,7 +39,6 @@
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],
Expand All @@ -51,14 +57,18 @@
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\TwigHooksBundle::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],
];
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
security:
enable_authenticator_manager: true
providers:
sylius_admin_user_provider:
id: sylius.admin_user_provider.email_or_name_based
Expand Down Expand Up @@ -93,32 +92,29 @@ security:
target: sylius_shop_homepage
invalidate_session: false

dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: 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 }
- { path: "%sylius.security.shop_regex%/login", role: PUBLIC_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.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.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 }
- { 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 }
2 changes: 1 addition & 1 deletion tests/Application/config/packages/validator.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
framework:
validation:
enable_annotations: true
enable_attributes: true
4 changes: 4 additions & 0 deletions tests/Application/config/routes/sylius_admin.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
sylius_admin:
resource: "@SyliusAdminBundle/Resources/config/routing.yml"
prefix: /admin

live_component:
resource: "@LiveComponentBundle/config/routes.php"
prefix: /_components
6 changes: 5 additions & 1 deletion tests/Application/config/routes/sylius_shop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ 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
3 changes: 3 additions & 0 deletions tests/Application/config/routes/ux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
live_component:
resource: "@LiveComponentBundle/config/routes.php"
prefix: /_components
Loading
Loading