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

OP-556 - Adding Sylius 2.0 support #58

Open
wants to merge 8 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,19 +20,12 @@ 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" ]
php: [ "8.2", "8.3" ]
symfony: ["^6.4", "^7.1" ]
sylius: [ "~2.0.0" ]
node: [ "20.x", "22.x" ]
mysql: [ "8.0" ]

exclude:
- sylius: ^1.13
php: 8.0
- sylius: ^1.12
php: 8.0
symfony: ^6.4

env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/coding_standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@ 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" ]

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: [ "~2.0.0" ]
node: [ "20.x", "22.x" ]
mysql: [ "8.0" ]

steps:
- uses: actions/checkout@v3
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ For the full installation guide, please go [here](doc/installation.md).

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 |
| Package | Version |
|---------------|---------------|
| PHP | \>=8.2 |
| sylius/sylius | 2.0.x |
| MySQL | \>= 8.0 |
| NodeJS | \>=20.x, 22.x |

----

Expand Down
73 changes: 41 additions & 32 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,59 @@
"description": "Shipping data export environment for Sylius platform applications",
"license": "MIT",
"require": {
"php": "^8.0",
"doctrine/dbal": "^2.7 || ^3.0",
"sylius/sylius": "~1.12.0 || ~1.13.0"
"php": "^8.2",
"sylius/sylius": "~2.0.0",
"dompdf/dompdf": "^2.0",
"sylius/twig-hooks": "^0.5",
"sylius/twig-extra": "^0.5",
"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.6.0",
"symfony/webpack-encore-bundle": "^1.15",
"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",
"behat/behat": "^3.14",
"behat/mink-selenium2-driver": "^1.7",
"bitbag/coding-standard": "^3.0.0",
"dmore/behat-chrome-extension": "^1.4",
"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",
"friends-of-behat/suite-settings-extension": "^1.1",
"friends-of-behat/symfony-extension": "^2.6",
"friends-of-behat/variadic-extension": "^1.6",
"gedmo/doctrine-extensions": "^3.9",
"lchrusciel/api-test-case": "^4.1 || ^5.0",
"league/flysystem-bundle": "^3.3",
"nelmio/alice": "^3.10",
"nyholm/psr7": "^1.8",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.8.1",
"phpstan/phpstan-doctrine": "1.3.69",
"phpstan/phpstan-strict-rules": "^1.3.0",
"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",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
"conflict": {
"doctrine/persistence": "<3.0"
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"robertfausk/behat-panther-extension": "^1.1",
"sylius-labs/coding-standard": "^4.4",
"sylius-labs/suite-tags-extension": "~0.2",
"sylius/mailer-bundle": "^1.8 || ^2.0@beta",
"sylius/sylius-rector": "^2.0",
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/debug-bundle": "^6.4 || ^7.1",
"symfony/dependency-injection": "^6.4 || ^7.1",
"symfony/dotenv": "^6.4 || ^7.1",
"symfony/http-client": "^6.4 || ^7.1",
"symfony/intl": "^6.4 || ^7.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.1"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"symfony/thanks": true,
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"php-http/discovery": true
}
},
"autoload": {
Expand Down
12 changes: 6 additions & 6 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ 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 |
| Package | Version |
|---------------|---------------|
| PHP | \>=8.2 |
| sylius/sylius | 2.0.x |
| MySQL | \>= 8.0 |
| NodeJS | \>=20.x, 22.x |

## Composer:
```bash
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ parameters:
paths:
- src

reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false

excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function editActionLinks(GridDefinitionConverterEvent $event): void
foreach ($this->shippingGateways as $shippingGatewayType => $shippingGatewayLabel) {
$options['links'][$shippingGatewayType] = [
'label' => $shippingGatewayLabel,
'icon' => 'plus',
'icon' => 'tabler:plus',
'route' => 'bitbag_admin_shipping_gateway_create',
'parameters' => [
'code' => $shippingGatewayType,
Expand Down
1 change: 0 additions & 1 deletion src/Repository/ShippingGatewayRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/**
* @template T of ResourceInterface
* @extends RepositoryInterface<T>
*/
interface ShippingGatewayRepositoryInterface extends RepositoryInterface
{
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ imports:
- { resource: "resource/**/*.yml" }
- { resource: "grids/**/*.yml" }
- { resource: "services.yml" }
- { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/twig_hooks/twig_hooks.yaml" }
4 changes: 2 additions & 2 deletions src/Resources/config/grids/bitbag_shipping_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ sylius_grid:
label: sylius.ui.create
options:
class: primary
icon: plus
icon: "tabler:plus"
header:
icon: cube
icon: "tabler:cube"
label: sylius.ui.type
links:
item:
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routing/bitbag_shipping_export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bitbag_admin_shipping_export:
resource: |
alias: bitbag.shipping_export
section: admin
templates: '@SyliusAdmin/Crud'
templates: "@SyliusAdmin\\shared\\crud"
only: ['index']
redirect: update
grid: bitbag_admin_shipping_export
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/routing/bitbag_shipping_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bitbag_admin_shipping_gateway:
resource: |
alias: bitbag.shipping_gateway
section: admin
templates: '@SyliusAdmin/Crud'
templates: "@SyliusAdmin\\shared\\crud"
except: ['show']
redirect: update
grid: bitbag_admin_shipping_gateway
Expand All @@ -25,7 +25,7 @@ bitbag_admin_shipping_gateway_create:
_controller: bitbag.controller.shipping_gateway::createAction
_sylius:
section: admin
template: '@SyliusAdmin/Crud/create.html.twig'
template: "@SyliusAdmin/shared/crud/create.html.twig"
redirect: bitbag_admin_shipping_gateway_index
permission: true
vars:
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/twig_hooks/twig_hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/twig_hooks/**/**/*.yaml" }
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<form action="{{ path('bitbag_admin_export_all_new_shipments') }}" method="POST">
<form action="{{ path('bitbag_admin_export_all_new_shipments') }}" method="POST" class="d-inline">
<input type="hidden" name="_method" value="PUT">
<button type="submit" class="ui labeled icon primary button export-all-new-shipments">
<i class="arrow up icon"></i>
<button type="submit" class="btn btn-primary gap-1">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-in-up" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M3.5 10a.5.5 0 0 1-.5-.5v-8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 0 0 1h2A1.5 1.5 0 0 0 14 9.5v-8A1.5 1.5 0 0 0 12.5 0h-9A1.5 1.5 0 0 0 2 1.5v8A1.5 1.5 0 0 0 3.5 11h2a.5.5 0 0 0 0-1z"/>
<path fill-rule="evenodd" d="M7.646 4.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 5.707V14.5a.5.5 0 0 1-1 0V5.707L5.354 7.854a.5.5 0 1 1-.708-.708z"/>
</svg>
{{ 'bitbag.ui.export_all_new_shipments'|trans }}
</button>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
{% if data.state == 'new' or data.state == 'pending' %}
{% include '@BitBagSyliusShippingExportPlugin/ShippingExport/Partial/_exportShipment.html.twig' %}
{% else %}
<span class="shipping-export-state ui green label"><i class="check icon"></i> {{ value|trans }}</span>
<button class="btn btn-success gap-1 shipping-export-state">
<svg viewBox="0 0 24 24" class="icon" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m5 12l5 5L20 7"></path></svg>
{{ value|trans }}
</button>
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<a href="{{ path('bitbag_admin_get_shipping_label', {'id' : data.id}) }}">
<button class="ui labeled icon teal button mini"><i class="file pdf outline icon"></i>
<button class="btn gap-1">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-envelope-arrow-down" viewBox="0 0 16 16">
<path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4.5a.5.5 0 0 1-1 0V5.383l-7 4.2-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h5.5a.5.5 0 0 1 0 1H2a2 2 0 0 1-2-1.99zm1 7.105 4.708-2.897L1 5.383zM1 4v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2a1 1 0 0 0-1 1"/>
<path d="M12.5 16a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7m.354-1.646a.5.5 0 0 1-.722-.016l-1.149-1.25a.5.5 0 1 1 .737-.676l.28.305V11a.5.5 0 0 1 1 0v1.793l.396-.397a.5.5 0 0 1 .708.708z"/>
</svg>
{{ 'bitbag.ui.download_shipping_label'|trans }}
</button>
</a>
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<form action="{{ path('bitbag_admin_export_single_shipment', {'id' : data.id}) }}" method="POST">
<input type="hidden" name="_method" value="PUT">
<button class="ui labeled icon {% if data.state == 'new' %} primary {% endif %} {% if data.state == 'pending' %} yellow {% endif %} button mini shipping-export-state">
<i class="{% if data.state == 'new' %} arrow up {% endif %} {% if data.state == 'pending' %} clock outline {% endif %} icon"></i>
<button class="btn{% if data.state == 'pending' %} btn-secondary{% endif %} gap-1 shipping-export-state">
{% if data.state == 'new' %}
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-in-up" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M3.5 10a.5.5 0 0 1-.5-.5v-8a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 0 0 1h2A1.5 1.5 0 0 0 14 9.5v-8A1.5 1.5 0 0 0 12.5 0h-9A1.5 1.5 0 0 0 2 1.5v8A1.5 1.5 0 0 0 3.5 11h2a.5.5 0 0 0 0-1z"/>
<path fill-rule="evenodd" d="M7.646 4.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 5.707V14.5a.5.5 0 0 1-1 0V5.707L5.354 7.854a.5.5 0 1 1-.708-.708z"/>
</svg>
{% elseif data.state == 'pending' %}
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clock-history" viewBox="0 0 16 16">
<path d="M8.515 1.019A7 7 0 0 0 8 1V0a8 8 0 0 1 .589.022zm2.004.45a7 7 0 0 0-.985-.299l.219-.976q.576.129 1.126.342zm1.37.71a7 7 0 0 0-.439-.27l.493-.87a8 8 0 0 1 .979.654l-.615.789a7 7 0 0 0-.418-.302zm1.834 1.79a7 7 0 0 0-.653-.796l.724-.69q.406.429.747.91zm.744 1.352a7 7 0 0 0-.214-.468l.893-.45a8 8 0 0 1 .45 1.088l-.95.313a7 7 0 0 0-.179-.483m.53 2.507a7 7 0 0 0-.1-1.025l.985-.17q.1.58.116 1.17zm-.131 1.538q.05-.254.081-.51l.993.123a8 8 0 0 1-.23 1.155l-.964-.267q.069-.247.12-.501m-.952 2.379q.276-.436.486-.908l.914.405q-.24.54-.555 1.038zm-.964 1.205q.183-.183.35-.378l.758.653a8 8 0 0 1-.401.432z"/>
<path d="M8 1a7 7 0 1 0 4.95 11.95l.707.707A8.001 8.001 0 1 1 8 0z"/>
<path d="M7.5 3a.5.5 0 0 1 .5.5v5.21l3.248 1.856a.5.5 0 0 1-.496.868l-3.5-2A.5.5 0 0 1 7 9V3.5a.5.5 0 0 1 .5-.5"/>
</svg>
{% endif %}
{{ value|trans }}
</button>
</form>
7 changes: 1 addition & 6 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Tests\BitBag\SyliusShippingExportPlugin\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;
Expand Down Expand Up @@ -113,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
Loading
Loading