Skip to content

Commit

Permalink
minor #312 Sylius 1.13 update (BartoszWojdalowicz)
Browse files Browse the repository at this point in the history
This PR was merged into the main branch.

Discussion
----------

Update plugin to sylius 1.13-dev. Drop support for sylius 1.11

Commits
-------
  Sylius 1.13 - Update composer.json
  Sylius 1.13 - Update test application config
  Sylius 1.13 - add workflow event
  Sylius 1.13 - update github actions config
  Sylius 1.13 - remove config for sylius 1.11
  Sylius 1.13 - Fix problem with wrong mink selenium version, fix bundles.php
  Sylius 1.13 - Fix bundles.php
  Sylius 1.13 - Change minimal sylius 1.12 version in gh actions
  Sylius 1.13 - Fix problem with workflow event
  Sylius 1.13 - Ignore 2 phpstan errors, add return type
  Sylius 1.13 - Fix ecs
  Sylius 1.13 - Fix behat scenarios
  Sylius 1.13 - Remove empty line
  Rename OrderPaymentPaidListener to ProduceOrderPaymentPaidListener
  Remove unnecessary config
  Add checking version of SyliusCoreBundle
  Update upgrade file
  Update readme file
  Add sylius state machin default adapter
  [Maintenance] Slight fixes of 1.13 support
  [Maintenance] Update builds
  [Maintenance] Update upgrade file
  [Maintenance] Update upgrade file
  [Maintenance] Remove default autoconfigure and autowire
  • Loading branch information
jakubtobiasz authored Mar 6, 2024
2 parents adeef13 + 1a40093 commit 0bf3e7c
Show file tree
Hide file tree
Showing 30 changed files with 159 additions and 127 deletions.
44 changes: 30 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,53 @@ jobs:
tests:
runs-on: ubuntu-latest

name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, wkhtmltopdf: ${{ matrix.wkhtmltopdf }}"
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, wkhtmltopdf: ${{ matrix.wkhtmltopdf }}, State Machine Adapter ${{ matrix.state_machine_adapter }}"

strategy:
fail-fast: false
matrix:
php: ["8.0", "8.1"]
symfony: ["^5.4", "^6.0"]
sylius: ["~1.11.10", "~1.12.0"]
node: ["16.x"]
mysql: ["5.7", "8.0"]
php: ["8.1", "8.2"]
symfony: ["^5.4.21", "^6.4"]
sylius: ["~1.12.0", "~1.13.x-dev",]
node: ["20.x"]
mysql: ["8.0"]
wkhtmltopdf: ["0.12.6-1"]
state_machine_adapter: [ "winzou_state_machine", "symfony_workflow" ]

include:
-
php: "8.1"
symfony: "^6.0"
php: "8.3"
symfony: "^6.4"
sylius: "~1.13.x-dev"
node: "20.x"
mysql: "8.0"
wkhtmltopdf: "0.12.6-1"
state_machine_adapter: "symfony_workflow"
-
php: "8.2"
symfony: "^6.4"
sylius: "~1.12.0"
node: "16.x"
node: "20.x"
mysql: "8.0"
wkhtmltopdf: false
state_machine_adapter: "winzou_state_machine"
-
php: "8.2"
symfony: "^6.4"
sylius: "~1.13.x-dev"
node: "20.x"
mysql: "8.0"
wkhtmltopdf: false
state_machine_adapter: "symfony_workflow"

exclude:
- php: "8.0"
symfony: "^6.0"

- symfony: "^6.0"
sylius: "~1.11.10"
- sylius: "~1.12.0"
state_machine_adapter: "symfony_workflow"

env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"
TEST_SYLIUS_STATE_MACHINE_ADAPTER: "${{ matrix.state_machine_adapter }}"

steps:
-
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ Symfony Flex, it's much quicker! :)
## Extension points
Majority of actions contained in SyliusInvoicingPlugin is executed once an event after changing the state of
the Order on `winzou_state_machine` is dispatched.
Majority of actions contained in SyliusInvoicingPlugin is executed once an event after changing the state of the Order.
Here is the example:
Here is the example for `Winzou State Machine`:
```yaml
winzou_state_machine:
Expand All @@ -92,6 +91,17 @@ winzou_state_machine:
Code placed above is a part of configuration placed in `config.yml` file.
You can customize this file by adding new state machine events listeners or editing existing ones.
Here is the example for Symfony's `workflow`:

```xml
<service id="sylius_invoicing_plugin.event_listener.workflow.payment.produce_order_payment_paid"
class="Sylius\InvoicingPlugin\EventListener\Workflow\Payment\ProduceOrderPaymentPaidListener">
<argument type="service" id="sylius_invoicing_plugin.event_producer.order_payment_paid" />
<tag name="kernel.event_listener" event="workflow.sylius_payment.completed.complete" priority="100" />
</service>
```

Apart from that an Invoice model is treated as a Resource.

You can read more about Resources here:
Expand Down
9 changes: 8 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
### UPGRADE FROM 0.23.X TO 0.24.0
### UPGRADE FROM 0.24.X TO 0.25.0

1. Support for Sylius 1.13 has been added, it is now the recommended Sylius version to use with InvoicingPlugin.
2. Support for Sylius 1.11 has been dropped, upgrade your application to [Sylius 1.12](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.12.md).
or to [Sylius 1.13](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.13.md).
3. Support for PHP 8.0 has been dropped.

### UPGRADE FROM 0.23.1 TO 0.24.0

1. Support for Sylius 1.12 has been added, it is now the recommended Sylius version to use with InvoicingPlugin.
2. Support for Sylius 1.10 has been dropped, upgrade your application to [Sylius 1.11](https://github.com/Sylius/Sylius/blob/master/UPGRADE-1.11.md).
Expand Down
48 changes: 24 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,51 @@
"description": "Invoicing plugin for Sylius.",
"license": "MIT",
"require": {
"php": "^8.0",
"php": "^8.1",
"knplabs/knp-snappy-bundle": "^1.8",
"ramsey/uuid": "^3.9 || ^4.0",
"sylius/grid-bundle": "^1.7",
"sylius/resource-bundle": "^1.6",
"sylius/sylius": "~1.11.0 || ~1.12.0",
"symfony/config": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/form": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/http-foundation": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"symfony/messenger": "^5.4 || ^6.0",
"symfony/options-resolver": "^5.4 || ^6.0",
"symfony/routing": "^5.4 || ^6.0"
"sylius/grid-bundle": "^1.9",
"sylius/resource-bundle": "^1.9",
"sylius/sylius": "~1.12.0 || ~1.13.x-dev",
"symfony/config": "^5.4 || ^6.4",
"symfony/dependency-injection": "^5.4.21 || ^6.4",
"symfony/form": "^5.4.21 || ^6.4",
"symfony/framework-bundle": "^5.4.21 || ^6.4",
"symfony/http-foundation": "^5.4.21 || ^6.4",
"symfony/http-kernel": "^5.4.21 || ^6.4",
"symfony/messenger": "^5.4.21 || ^6.4",
"symfony/options-resolver": "^5.4.21 || ^6.4",
"symfony/routing": "^5.4.21 || ^6.4"
},
"require-dev": {
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"behat/mink-selenium2-driver": "~1.6.0",
"friends-of-behat/exclude-specifications-extension": "^0.2 || ^0.3",
"friends-of-behat/mink": "^1.8",
"friends-of-behat/mink-browserkit-driver": "^1.3",
"friends-of-behat/mink-browserkit-driver": "^1.4",
"friends-of-behat/mink-debug-extension": "^2.0",
"friends-of-behat/mink-extension": "^2.3",
"friends-of-behat/mink-extension": "^2.4",
"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",
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"phpspec/phpspec": "^7.0",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"phpspec/phpspec": "^7.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-symfony": "^1.2",
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius-labs/coding-standard": "~4.0.0",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/browser-kit": "^5.4.21 || ^6.4",
"symfony/debug-bundle": "^5.4.21 || ^6.4",
"symfony/dotenv": "^5.4.21 || ^6.4",
"symfony/intl": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.15",
"symfony/web-profiler-bundle": "^5.4 || ^6.0"
"symfony/web-profiler-bundle": "^5.4.21 || ^6.4"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion features/managing_invoices/filtering_invoices.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Filtering invoices
And the store has a zone "Germany + France" with code "DE + FR"
And this zone has the "Germany" country member
And this zone has the "France" country member
And the store has a product "PHP T-Shirt" priced at "€10" available in channel "WEB-DE" and channel "WEB-FR"
And the store has a product "PHP T-Shirt" priced at "€10.00" available in channel "WEB-DE" and channel "WEB-FR"
And the store ships everywhere for free for all channels
And the store allows paying offline for all channels
And there is a customer "[email protected]" that placed an order "#00000022"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Seeing an invoice with items having promotion applied
And there is a promotion "50% shipping discount"
And it gives "50%" discount on shipping to every order
And there is a promotion "Anatomy Park Promotion"
And this promotion gives "$1" off on every product with minimum price at "$5.00"
And this promotion gives "$1.00" off on every product with minimum price at "$5.00"
And there is a customer "[email protected]" that placed an order "#00000666"
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Seeing an invoice with items and shipment having promotion applied
And the store has "Galaxy Post" shipping method with "$20.00" fee
And the store allows paying with "Space money"
And there is a promotion "Anatomy Park Promotion"
And this promotion gives "$10" discount to every order with items total at least "$15.00"
And this promotion gives "$10.00" discount to every order with items total at least "$15.00"
And there is a customer "[email protected]" that placed an order "#00000666"
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Seeing included in price taxes and promotions applied on an invoice
And the store has "UPS" shipping method with "$10.00" fee
And the store allows paying with "Cash on Delivery"
And there is a promotion "Anatomy Park Promotion"
And this promotion gives "$10" off on every product with minimum price at "$5.00"
And this promotion gives "$10.00" off on every product with minimum price at "$5.00"
And there is a customer "[email protected]" that placed an order "#00000666"
And the customer bought 2 "PHP T-Shirt" products
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\InvoicingPlugin\EventListener\Workflow\Payment;

use Sylius\Component\Core\Model\PaymentInterface;
use Sylius\InvoicingPlugin\EventProducer\OrderPaymentPaidProducer;
use Symfony\Component\Workflow\Event\CompletedEvent;
use Webmozart\Assert\Assert;

final class ProduceOrderPaymentPaidListener
{
public function __construct(
private readonly OrderPaymentPaidProducer $orderPaymentPaidProducer,
) {
}

/** @phpstan-ignore-next-line */
public function __invoke(CompletedEvent $event): void
{
/** @phpstan-ignore-next-line */
$payment = $event->getSubject();
Assert::isInstanceOf($payment, PaymentInterface::class);

$this->orderPaymentPaidProducer->__invoke($payment);
}
}
4 changes: 2 additions & 2 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<imports>
<import resource="services/*.xml" />
<import resource="services/**.xml" />
</imports>

<parameters>
Expand All @@ -11,7 +11,7 @@
</parameters>

<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.date_time_provider" class="Sylius\InvoicingPlugin\SystemDateTimeProvider" />

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.ui.action.download_invoice" class="Sylius\InvoicingPlugin\Ui\Action\DownloadInvoiceAction">
<argument type="service" id="sylius_invoicing_plugin.repository.invoice" />
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/cli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.cli.generate_invoices" class="Sylius\InvoicingPlugin\Cli\GenerateInvoicesCommand">
<argument type="service" id="sylius_invoicing_plugin.creator.mass_invoices" />
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/converters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.converter.order_item_units_to_line_items" class="Sylius\InvoicingPlugin\Converter\OrderItemUnitsToLineItemsConverter">
<argument type="service" id="sylius_invoicing_plugin.provider.tax_rate_percentage" />
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/fixtures.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.fixture.example_factory.invoicing_plugin_shop_billing_data" class="Sylius\InvoicingPlugin\Fixture\Factory\ShopBillingDataExampleFactory">
<argument id="sylius.repository.channel" type="service"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/generators.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.generator.invoice_number_generator" class="Sylius\InvoicingPlugin\Generator\SequentialInvoiceNumberGenerator">
<argument type="service" id="sylius_invoicing_plugin.repository.invoice_sequence" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.event_producer.order_payment_paid" class="Sylius\InvoicingPlugin\EventProducer\OrderPaymentPaidProducer">
<argument type="service" id="sylius.event_bus" />
Expand Down
14 changes: 14 additions & 0 deletions src/Resources/config/services/listeners/workflow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius_invoicing_plugin.event_listener.workflow.payment.produce_order_payment_paid"
class="Sylius\InvoicingPlugin\EventListener\Workflow\Payment\ProduceOrderPaymentPaidListener">
<argument type="service" id="sylius_invoicing_plugin.event_producer.order_payment_paid" />

<tag name="kernel.event_listener" event="workflow.sylius_payment.completed.complete" priority="100" />
</service>
</services>
</container>
2 changes: 1 addition & 1 deletion src/Resources/config/services/ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autoconfigure="true" autowire="true" public="true" />
<defaults public="true" />

<service id="sylius_invoicing_plugin.ui.menu.admin_menu_listener" class="Sylius\InvoicingPlugin\Ui\Menu\AdminMenuListener">
<tag name="kernel.event_listener" event="sylius.menu.admin.main" method="__invoke" />
Expand Down
11 changes: 10 additions & 1 deletion tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

return [
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;

$bundles = [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true],
Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true],
Expand Down Expand Up @@ -58,3 +61,9 @@
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
];

if (SyliusCoreBundle::VERSION_ID >= '11300') {
$bundles[Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class] = ['all' => true];
}

return $bundles;

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0bf3e7c

Please sign in to comment.