Skip to content

Commit d1c1037

Browse files
authored
Add Symfony 8 support (#276)
## Summary Add Symfony 8 support. Changes: - Add ^8.0 to all Symfony package constraints - Update CI workflow to test with PHP 8.4 and Symfony 8.0 - Migrate from XML to PHP service configuration (XmlFileLoader removed in Symfony 8) - Update phpunit/phpunit to ^10.5 || ^11.0 - Update matthiasnoback/symfony-dependency-injection-test to ^5.0 || ^6.1
2 parents 5fbde25 + 69d7efb commit d1c1037

File tree

13 files changed

+278
-129
lines changed

13 files changed

+278
-129
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
php: ["8.2", "8.3", "8.4", "8.5"]
21-
symfony: ["^6.4", "^7.4"]
21+
symfony: ["^6.4", "^7.4", "^8.0"]
22+
exclude:
23+
- php: "8.2"
24+
symfony: "^8.0"
25+
- php: "8.3"
26+
symfony: "^8.0"
2227

2328
steps:
2429
-
@@ -30,13 +35,12 @@ jobs:
3035
with:
3136
php-version: "${{ matrix.php }}"
3237
coverage: none
38+
tools: 'composer:v2, flex'
3339

3440
-
3541
name: Restrict Symfony version
3642
if: matrix.symfony != ''
3743
run: |
38-
composer global config --no-plugins allow-plugins.symfony/flex true
39-
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
4044
composer config extra.symfony.require "${{ matrix.symfony }}"
4145
(cd src/Component && composer config extra.symfony.require "${{ matrix.symfony }}")
4246

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88

99
/.phpunit.result.cache
1010
.phpunit.cache/
11+
tests/Application/config/reference.php

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
],
2626
"require": {
2727
"php": "^8.2",
28-
"symfony/config": "^6.4 || ^7.4",
28+
"symfony/config": "^6.4 || ^7.4 || ^8.0",
2929
"symfony/event-dispatcher-contracts": "^3.0",
30-
"symfony/dependency-injection": "^6.4 || ^7.4",
31-
"symfony/framework-bundle": "^6.4 || ^7.4",
32-
"symfony/http-kernel": "^6.4 || ^7.4",
30+
"symfony/dependency-injection": "^6.4 || ^7.4 || ^8.0",
31+
"symfony/framework-bundle": "^6.4 || ^7.4 || ^8.0",
32+
"symfony/http-kernel": "^6.4 || ^7.4 || ^8.0",
3333
"twig/twig": "^3.3",
3434
"webmozart/assert": "^1.9"
3535
},
@@ -43,11 +43,11 @@
4343
"phpstan/phpstan-webmozart-assert": "1.2.11",
4444
"phpunit/phpunit": "^11.5",
4545
"sylius-labs/coding-standard": "^4.0",
46-
"symfony/console": "^6.4 || ^7.4",
47-
"symfony/dotenv": "^6.4 || ^7.4",
48-
"symfony/event-dispatcher": "^6.4 || ^7.4",
49-
"symfony/mailer": "^6.4 || ^7.4",
50-
"symfony/twig-bundle": "^6.4 || ^7.4"
46+
"symfony/console": "^6.4 || ^7.4 || ^8.0",
47+
"symfony/dotenv": "^6.4 || ^7.4 || ^8.0",
48+
"symfony/event-dispatcher": "^6.4 || ^7.4 || ^8.0",
49+
"symfony/mailer": "^6.4 || ^7.4 || ^8.0",
50+
"symfony/twig-bundle": "^6.4 || ^7.4 || ^8.0"
5151
},
5252
"suggest": {
5353
"symfony/translation": "To use the translation features for testing purposes"

src/Bundle/DependencyInjection/SyliusMailerExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
use Symfony\Component\Config\FileLocator;
1919
use Symfony\Component\DependencyInjection\Alias;
2020
use Symfony\Component\DependencyInjection\ContainerBuilder;
21-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
21+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
2222
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
2323

2424
final class SyliusMailerExtension extends ConfigurableExtension
2525
{
2626
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
2727
{
28-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
29-
$loader->load('services.xml');
28+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
29+
$loader->load('services.php');
3030

3131
$this->configureSenderAdapter($mergedConfig, $container);
3232
$this->configureRendererAdapter($mergedConfig, $container);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
15+
16+
return static function (ContainerConfigurator $container): void {
17+
$container->import('services/factory.php');
18+
$container->import('services/provider.php');
19+
$container->import('services/renderer.php');
20+
$container->import('services/sender.php');
21+
$container->import('services/modifier.php');
22+
$container->import('services/console.php');
23+
};

src/Bundle/Resources/config/services.xml

Lines changed: 0 additions & 113 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
15+
16+
use Sylius\Bundle\MailerBundle\Console\Command\DebugMailerCommand;
17+
use Sylius\Bundle\MailerBundle\Console\Command\Dumper\EmailDetailDumperInterface;
18+
use Sylius\Bundle\MailerBundle\Console\Command\Dumper\EmailDetailsDumper;
19+
use Sylius\Bundle\MailerBundle\Console\Command\Dumper\EmailsListDumper;
20+
use Sylius\Bundle\MailerBundle\Console\Command\Dumper\SenderDataDumper;
21+
use Symfony\Contracts\Translation\TranslatorInterface;
22+
23+
return static function (ContainerConfigurator $container): void {
24+
$services = $container->services();
25+
$services->defaults()->public();
26+
27+
$services->set(EmailDetailDumperInterface::class, EmailDetailsDumper::class)
28+
->args([
29+
'%sylius.mailer.emails%',
30+
service(TranslatorInterface::class)->nullOnInvalid(),
31+
service('twig.loader'),
32+
]);
33+
34+
$services->set(EmailsListDumper::class)
35+
->args([
36+
'%sylius.mailer.emails%',
37+
service(TranslatorInterface::class)->nullOnInvalid(),
38+
])
39+
->tag('sylius_mailer.dumper');
40+
41+
$services->set(SenderDataDumper::class)
42+
->args([
43+
'%sylius.mailer.sender_name%',
44+
'%sylius.mailer.sender_address%',
45+
])
46+
->tag('sylius_mailer.dumper');
47+
48+
$services->set(DebugMailerCommand::class)
49+
->autoconfigure()
50+
->args([
51+
tagged_iterator('sylius_mailer.dumper'),
52+
service(EmailDetailDumperInterface::class),
53+
]);
54+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
15+
16+
use Sylius\Component\Mailer\Factory\EmailFactory;
17+
use Sylius\Component\Mailer\Factory\EmailFactoryInterface;
18+
19+
return static function (ContainerConfigurator $container): void {
20+
$services = $container->services();
21+
$services->defaults()->public();
22+
23+
$services->set('sylius.factory.email', EmailFactory::class);
24+
$services->alias(EmailFactoryInterface::class, 'sylius.factory.email');
25+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
15+
16+
use Sylius\Component\Mailer\Modifier\CompositeEmailModifier;
17+
use Sylius\Component\Mailer\Modifier\EmailModifierInterface;
18+
19+
return static function (ContainerConfigurator $container): void {
20+
$services = $container->services();
21+
$services->defaults()->public();
22+
23+
$services->set(EmailModifierInterface::class, CompositeEmailModifier::class)
24+
->args([
25+
tagged_iterator('sylius_mailer.email_modifier'),
26+
]);
27+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
15+
16+
use Sylius\Component\Mailer\Provider\DefaultSettingsProvider;
17+
use Sylius\Component\Mailer\Provider\DefaultSettingsProviderInterface;
18+
use Sylius\Component\Mailer\Provider\EmailProvider;
19+
use Sylius\Component\Mailer\Provider\EmailProviderInterface;
20+
21+
return static function (ContainerConfigurator $container): void {
22+
$services = $container->services();
23+
$services->defaults()->public();
24+
25+
$services->set('sylius.email_provider', EmailProvider::class)
26+
->args([
27+
service('sylius.factory.email'),
28+
'%sylius.mailer.emails%',
29+
]);
30+
$services->alias(EmailProviderInterface::class, 'sylius.email_provider');
31+
32+
$services->set('sylius.mailer.default_settings_provider', DefaultSettingsProvider::class)
33+
->args([
34+
'%sylius.mailer.sender_name%',
35+
'%sylius.mailer.sender_address%',
36+
]);
37+
$services->alias(DefaultSettingsProviderInterface::class, 'sylius.mailer.default_settings_provider');
38+
};

0 commit comments

Comments
 (0)