Skip to content

Commit

Permalink
feature #254 Allow for Sylius 1.8 & 1.9 and Symfony 4.4 & 5.2 (pamil,…
Browse files Browse the repository at this point in the history
… GSadee)

This PR was merged into the 1.0-dev branch.

Discussion
----------



Commits
-------

83a41a2 Allow for Sylius 1.8 & 1.9 and Symfony 4.4 & 5.2
ef1a55f Replace usage of Symfony\Bundle\FrameworkBundle\Templating\EngineInterface with Twig\Environment
d8d85ea Replace deprecated Doctrine\Common\Persistence namespace with Doctrine\Persistence.
6ba5b45 Remove duplicated migrations for Sylius 1.9
8b75d6a Remove unnecessary server version from .env
e682a3b Exclude duplicated migrations for Sylius 1.9 in GitHub Actions builds
e255009 Use proper service as a command bus
b54f105 Remove unnecessary config for default bus
59dcf0f Fix references to templates
6408dca Update UPGRADE and README notes
853f9ff Minor improvement in Configuration file
ad898fd Update duplicated migrations not to execute if the changes already exist in db
  • Loading branch information
GSadee authored Feb 17, 2021
2 parents b1d6c06 + ad898fd commit 6d5338e
Show file tree
Hide file tree
Showing 49 changed files with 176 additions and 106 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ on:

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04

name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}"
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"

strategy:
fail-fast: false
matrix:
php: [7.4, 7.3]
symfony: [^4.4, ^5.2]
sylius: [~1.8.0, ~1.9.0@beta]
node: [10.x]
mysql: [5.7, 8.0]
sylius: [1.8.*]

exclude:
-
php: 7.3
mysql: 8.0
-
sylius: ~1.8.0
symfony: ^5.2

env:
APP_ENV: test
Expand Down Expand Up @@ -92,15 +96,23 @@ jobs:
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
- name: Prepare migrations
run: |
composer require sylius-labs/doctrine-migrations-extra-bundle --no-interaction --no-update
-
name: Install Sylius version
run: |
composer require "sylius/sylius:${{ matrix.sylius }}" --no-update
-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"
-
name: Restrict Sylius version
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

-
name: Install PHP dependencies
run: composer update --no-interaction
Expand Down Expand Up @@ -161,7 +173,7 @@ jobs:

-
name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun
run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun

-
name: Upload Behat logs
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ It is used by `KnpSnappyBundle` and can be configured according to [their documm
cp -R vendor/sylius/refund-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
```

4. (optional) If you don't use `symfony/messenger` component yet, it is required to configure one of the message buses as a default bus:
```yaml
framework:
messenger:
default_bus: sylius_refund_plugin.command_bus
```
#### Beware!

This installation instruction assumes that you're using Symfony Flex. If you don't, take a look at the
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@
"knplabs/knp-snappy-bundle": "^1.7",
"myclabs/php-enum": "^1.7",
"sylius/resource-bundle": "^1.6",
"sylius/sylius": "^1.8",
"symfony/messenger": "^4.4"
"sylius/sylius": "~1.8.0 || ~1.9.0@beta",
"symfony/messenger": "^4.4 || ^5.2"
},
"require-dev": {
"behat/behat": "^3.6",
"behat/mink": "^1.8",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.3",
"behat/mink-selenium2-driver": "^1.4",
"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.3",
"friends-of-behat/mink-extension": "^2.3",
"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",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"lakion/mink-debug-extension": "^1.2.3",
"phpspec/phpspec": "^6.0",
"phpstan/phpstan": "0.12.29",
"phpstan/phpstan-webmozart-assert": "0.12.6",
"phpunit/phpunit": "^8.5",
"sylius-labs/coding-standard": "^3.2",
"symfony/browser-kit": "^4.4",
"symfony/debug-bundle": "^4.4",
"symfony/dotenv": "^4.4",
"symfony/intl": "^4.4",
"symfony/web-profiler-bundle": "^4.4",
"symfony/web-server-bundle": "^4.4"
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
"symfony/intl": "^4.4 || ^5.2",
"symfony/web-profiler-bundle": "^4.4 || ^5.2"
},
"autoload": {
"psr-4": {
Expand Down
23 changes: 7 additions & 16 deletions docs/legacy_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
composer require sylius/refund-plugin
```

2. Add plugin class and other required bundles to your `AppKernel`:
1. Add plugin class and other required bundles to your `AppKernel`:

```php
$bundles = [
Expand All @@ -15,20 +15,20 @@
];
```

3. Import configuration:
1. Import configuration:

```yaml
imports:
- { resource: "@SyliusRefundPlugin/Resources/config/app/config.yml" }
```
4. Import routing:
1. Import routing:
````yaml
sylius_refund:
resource: "@SyliusRefundPlugin/Resources/config/routing.yml"
````
5. Configure `KnpSnappyBundle` (if you don't have it configured yet):
1. Configure `KnpSnappyBundle` (if you don't have it configured yet):
````yaml
knp_snappy:
Expand All @@ -38,30 +38,21 @@
options: []
````
6. Copy plugin migrations to your migrations directory (e.g. `src/Migrations`) and apply them to your database:
1. Apply migrations to your database:
```bash
cp -R vendor/sylius/refund-plugin/migrations/* src/Migrations
bin/console doctrine:migrations:migrate
```
7. Copy Sylius templates overridden in plugin to your templates directory (e.g `templates/bundles/`):
1. Copy Sylius templates overridden in plugin to your templates directory (e.g `templates/bundles/`):
```bash
mkdir -p templates/bundles/SyliusAdminBundle/
cp -R vendor/sylius/refund-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
```
8. Clear cache:
1. Clear cache:
```bash
bin/console cache:clear
```
9. (optional) If you don't use `symfony/messenger` component yet, it is required to configure one of the message buses as a default bus:
```yaml
framework:
messenger:
default_bus: sylius_refund_plugin.command_bus
```
2 changes: 1 addition & 1 deletion spec/CommandHandler/GenerateCreditMemoHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\CommandHandler;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
Expand Down
2 changes: 1 addition & 1 deletion spec/Creator/RefundCreatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\Creator;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Sylius\RefundPlugin\Creator\RefundCreatorInterface;
use Sylius\RefundPlugin\Entity\RefundInterface;
Expand Down
6 changes: 3 additions & 3 deletions spec/Generator/CreditMemoPdfFileGeneratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
use Sylius\RefundPlugin\Generator\CreditMemoPdfFileGeneratorInterface;
use Sylius\RefundPlugin\Model\CreditMemoPdf;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Templating\EngineInterface;
use Twig\Environment;

final class CreditMemoPdfFileGeneratorSpec extends ObjectBehavior
{
function let(
RepositoryInterface $creditMemoRepository,
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator
): void {
Expand All @@ -39,7 +39,7 @@ function it_implements_credit_memo_pdf_file_generator_interface(): void

function it_creates_credit_memo_pdf_with_generated_content_and_filename_basing_on_credit_memo_number(
RepositoryInterface $creditMemoRepository,
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator,
CreditMemoInterface $creditMemo
Expand Down
2 changes: 1 addition & 1 deletion spec/Generator/SequentialNumberGeneratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\Generator;

use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\Persistence\ObjectRepository;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\EntityManagerInterface;
use PhpSpec\ObjectBehavior;
Expand Down
2 changes: 1 addition & 1 deletion spec/StateResolver/OrderFullyRefundedStateResolverSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\StateResolver;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use SM\Factory\FactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\StateResolver;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use SM\Factory\FactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\StateResolver;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
use SM\StateMachine\StateMachineInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Action/CompleteRefundPaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\Action;

use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\Persistence\ObjectRepository;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\RefundPlugin\Entity\RefundPaymentInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/CommandHandler/GenerateCreditMemoHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\CommandHandler;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\RefundPlugin\Command\GenerateCreditMemo;
Expand Down
2 changes: 1 addition & 1 deletion src/Creator/RefundCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\Creator;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Sylius\RefundPlugin\Exception\UnitAlreadyRefundedException;
use Sylius\RefundPlugin\Factory\RefundFactoryInterface;
use Sylius\RefundPlugin\Model\RefundType;
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ final class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_refund_plugin');

return $treeBuilder;
return new TreeBuilder('sylius_refund_plugin');
}
}
6 changes: 3 additions & 3 deletions src/Generator/CreditMemoPdfFileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Sylius\RefundPlugin\Exception\CreditMemoNotFound;
use Sylius\RefundPlugin\Model\CreditMemoPdf;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Templating\EngineInterface;
use Twig\Environment;

final class CreditMemoPdfFileGenerator implements CreditMemoPdfFileGeneratorInterface
{
Expand All @@ -19,7 +19,7 @@ final class CreditMemoPdfFileGenerator implements CreditMemoPdfFileGeneratorInte
/** @var RepositoryInterface */
private $creditMemoRepository;

/** @var EngineInterface */
/** @var Environment */
private $twig;

/** @var GeneratorInterface */
Expand All @@ -36,7 +36,7 @@ final class CreditMemoPdfFileGenerator implements CreditMemoPdfFileGeneratorInte

public function __construct(
RepositoryInterface $creditMemoRepository,
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator,
string $template,
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/SequentialNumberGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\Generator;

use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\Persistence\ObjectRepository;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\EntityManagerInterface;
use Sylius\RefundPlugin\Entity\CreditMemoSequenceInterface;
Expand Down
5 changes: 5 additions & 0 deletions src/Migrations/Version20201130071338.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function getDescription(): string

public function up(Schema $schema): void
{
$adjustmentTable = $schema->getTable('sylius_adjustment');
if ($adjustmentTable->hasColumn('shipment_id')) {
return;
}

$this->addSql('ALTER TABLE sylius_adjustment ADD shipment_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE sylius_adjustment ADD CONSTRAINT FK_ACA6E0F27BE036FC FOREIGN KEY (shipment_id) REFERENCES sylius_shipment (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_ACA6E0F27BE036FC ON sylius_adjustment (shipment_id)');
Expand Down
5 changes: 5 additions & 0 deletions src/Migrations/Version20201204071301.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function getDescription(): string

public function up(Schema $schema): void
{
$adjustmentTable = $schema->getTable('sylius_adjustment');
if ($adjustmentTable->hasColumn('details')) {
return;
}

$this->addSql('ALTER TABLE sylius_adjustment ADD details JSON NOT NULL');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/admin_routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sylius_refund_credit_memo:
resource: |
alias: sylius_refund.credit_memo
section: admin
templates: SyliusAdminBundle:Crud
templates: "@SyliusAdmin\\Crud"
only: ['index']
grid: sylius_refund_credit_memo
permission: true
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/generator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<service id="Sylius\RefundPlugin\Generator\CreditMemoPdfFileGenerator">
<argument type="service" id="sylius_refund.repository.credit_memo" />
<argument type="service" id="templating.engine.twig" />
<argument type="service" id="twig" />
<argument type="service" id="knp_snappy.pdf" />
<argument type="service" id="file_locator" />
<argument>@SyliusRefundPlugin/Download/creditMemo.html.twig</argument>
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Grid/Filter/channel.html.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% form_theme form 'SyliusUiBundle:Form:theme.html.twig' %}
{% form_theme form '@SyliusUi/Form/theme.html.twig' %}

{{ form_row(form) }}
2 changes: 1 addition & 1 deletion src/Resources/views/orderRefunds.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'SyliusAdminBundle::layout.html.twig' %}
{% extends '@SyliusAdmin/layout.html.twig' %}

{% block title %}{{ 'sylius.ui.order'|trans ~' #'~ order.number }} {{ 'sylius_refund.ui.refunds'|trans }} {{ parent() }}{% endblock %}

Expand Down
Loading

0 comments on commit 6d5338e

Please sign in to comment.