Skip to content

Commit

Permalink
feature #87 Remove sylius/currency-bundle dev dependency (pamil)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.8-dev branch.

Discussion
----------

Based on @stloyd idea from #66, thanks a lot!

Closes #66.

Commits
-------

2bb8545 Remove sylius/currency-bundle from dev dependencies
f511d0d Do not register MoneyFilter and MoneyFilterType unless SyliusCurrencyBundle exists
0ee8da0 Deprecate MoneyFilter and MoneyFilterType
6e11a0a Suggest sylius/currency-bundle as an optional package
223aa85 Fix static analysis
02932be Add sylius/resource-bundle which was a needed transient dependency
c0e816c Add a build to test the package with currency bundle included
  • Loading branch information
pamil authored Nov 24, 2020
2 parents 894f877 + c0e816c commit 002b6b1
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 10 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
name: "PHP ${{ matrix.php }}${{ matrix.symfony != '' && format(', Symfony {0}', matrix.symfony) || '' }}${{ matrix.currency-bundle != '' && format(', CurrencyBundle {0}', matrix.currency-bundle) || '' }}"
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4]
symfony: [4.4.*]
include:
-
php: 7.3
symfony: 4.4.*
-
php: 7.4
symfony: 4.4.*
-
php: 7.4
currency-bundle: "^1.7"

steps:
-
Expand All @@ -38,6 +46,12 @@ jobs:
composer config extra.symfony.require "${{ matrix.symfony }}"
(cd src/Component && composer config extra.symfony.require "${{ matrix.symfony }}")
-
name: Require sylius/currency-bundle
if: matrix.currency-bundle != ''
run: |
composer require "sylius/currency-bundle:${{ matrix.currency-bundle }}"
-
name: Install dependencies
run: |
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"sylius/registry": "^1.5",
"symfony/config": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
"symfony/deprecation-contracts": "^2.2",
"symfony/event-dispatcher": "^4.4 || ^5.1",
"symfony/form": "^4.4 || ^5.1",
"symfony/framework-bundle": "^4.4 || ^5.1",
Expand Down Expand Up @@ -64,13 +65,16 @@
"phpstan/phpstan-webmozart-assert": "0.12.7",
"phpunit/phpunit": "^9.4",
"sylius-labs/coding-standard": "^3.0",
"sylius/currency-bundle": "^1.7",
"sylius/resource-bundle": "^1.6",
"symfony/console": "^4.4 || ^5.1",
"symfony/twig-bundle": "^4.4 || ^5.1",
"twig/extensions": "^1.5",
"twig/twig": "^2.12 || ^3.0",
"vimeo/psalm": "4.2.1"
},
"suggest": {
"sylius/currency-bundle": "^1.7"
},
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ parameters:
ignoreErrors:
- '/Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\./'
- '/Method Sylius\\Component\\Grid\\Definition\\Filter::setCriteria\(\) has no return typehint specified\./'
- '/Class Sylius\\Bundle\\CurrencyBundle\\Form\\Type\\CurrencyChoiceType not found\./'
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<errorLevel type="suppress">
<referencedClass name="Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass" />
<referencedClass name="Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass" />
<referencedClass name="Sylius\Bundle\CurrencyBundle\Form\Type\CurrencyChoiceType" />
<referencedClass name="Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheAdapter" />
<referencedClass name="Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface" />
</errorLevel>
Expand Down
5 changes: 5 additions & 0 deletions src/Bundle/DependencyInjection/SyliusGridExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sylius\Bundle\GridBundle\DependencyInjection;

use Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle;
use Sylius\Bundle\GridBundle\SyliusGridBundle;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -47,6 +48,10 @@ public function load(array $configs, ContainerBuilder $container): void

$loader->load(sprintf('services/integrations/%s.xml', $enabledDriver));
}

if (\class_exists(SyliusCurrencyBundle::class)) {
$loader->load('services/integrations/sylius_currency_bundle.xml');
}
}

public function getConfiguration(array $config, ContainerBuilder $container): Configuration
Expand Down
2 changes: 2 additions & 0 deletions src/Bundle/Form/Type/Filter/MoneyFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

\trigger_deprecation('sylius/grid-bundle', '1.8', '%s is deprecated, replace it with your own implementation.', MoneyFilterType::class);

final class MoneyFilterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
6 changes: 0 additions & 6 deletions src/Bundle/Resources/config/services/filters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
<service id="sylius.form.type.grid_filter.entity" class="Sylius\Bundle\GridBundle\Form\Type\Filter\EntityFilterType">
<tag name="form.type" />
</service>
<service id="sylius.grid_filter.money" class="Sylius\Component\Grid\Filter\MoneyFilter">
<tag name="sylius.grid_filter" type="money" form-type="Sylius\Bundle\GridBundle\Form\Type\Filter\MoneyFilterType" />
</service>
<service id="sylius.form.type.grid_filter.money" class="Sylius\Bundle\GridBundle\Form\Type\Filter\MoneyFilterType">
<tag name="form.type" />
</service>
<service id="sylius.grid_filter.exists" class="Sylius\Component\Grid\Filter\ExistsFilter">
<tag name="sylius.grid_filter" type="exists" form-type="Sylius\Bundle\GridBundle\Form\Type\Filter\ExistsFilterType" />
</service>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->

<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.grid_filter.money" class="Sylius\Component\Grid\Filter\MoneyFilter">
<tag name="sylius.grid_filter" type="money" form-type="Sylius\Bundle\GridBundle\Form\Type\Filter\MoneyFilterType" />
</service>
<service id="sylius.form.type.grid_filter.money" class="Sylius\Bundle\GridBundle\Form\Type\Filter\MoneyFilterType">
<tag name="form.type" />
</service>
</services>
</container>
2 changes: 2 additions & 0 deletions src/Component/Filter/MoneyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Sylius\Component\Grid\Data\DataSourceInterface;
use Sylius\Component\Grid\Filtering\FilterInterface;

\trigger_deprecation('sylius/grid', '1.8', '%s is deprecated, replace it with your own implementation.', MoneyFilter::class);

final class MoneyFilter implements FilterInterface
{
public const DEFAULT_SCALE = 2;
Expand Down
1 change: 1 addition & 0 deletions src/Component/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"php": "^7.3",
"sylius-labs/polyfill-symfony-event-dispatcher": "^1.0",
"sylius/registry": "^1.5",
"symfony/deprecation-contracts": "^2.2",
"symfony/event-dispatcher": "^4.4 || ^5.1",
"webmozart/assert": "^1.9"
},
Expand Down

0 comments on commit 002b6b1

Please sign in to comment.