Skip to content

Commit a2f2c91

Browse files
committed
Support Symfony 6
1 parent d7c483b commit a2f2c91

File tree

10 files changed

+52
-86
lines changed

10 files changed

+52
-86
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
php: ["8.0", "8.1"]
25-
symfony: ["5.4.*"]
25+
symfony: ["5.4.*", "^6.0"]
2626
sylius: ["^1.12"]
2727
node: ["14.x", "16.x", "18.x"]
2828
mysql: ["5.7", "8.0"]
@@ -97,6 +97,12 @@ jobs:
9797
composer global config --no-plugins allow-plugins.symfony/flex true
9898
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.2.2"
9999
100+
-
101+
name: Restrict Symfony version
102+
if: matrix.symfony != ''
103+
run: |
104+
composer config extra.symfony.require "${{ matrix.symfony }}"
105+
100106
-
101107
name: Restrict Sylius version
102108
if: matrix.sylius != ''

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"require": {
1111
"php": "^8.0",
1212
"sylius/sylius": "^1.12",
13+
"sylius/mailer-bundle": "^1.8 || ^2.0@beta",
1314
"symfony/webpack-encore-bundle": "^1.15"
1415
},
1516
"require-dev": {
@@ -25,7 +26,6 @@
2526
"friends-of-behat/suite-settings-extension": "^1.0",
2627
"friends-of-behat/symfony-extension": "^2.1",
2728
"friends-of-behat/variadic-extension": "^1.3",
28-
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
2929
"phpspec/phpspec": "^7.2",
3030
"phpstan/extension-installer": "^1.0",
3131
"phpstan/phpstan": "^1.8.1",
@@ -34,14 +34,13 @@
3434
"phpstan/phpstan-webmozart-assert": "^1.2.0",
3535
"phpunit/phpunit": "^9.5",
3636
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
37-
"sensiolabs/security-checker": "^6.0",
3837
"sylius-labs/coding-standard": "^4.2",
39-
"symfony/browser-kit": "^5.4",
40-
"symfony/debug-bundle": "^5.4",
41-
"symfony/dotenv": "^5.4",
38+
"symfony/browser-kit": "^5.4 || ^6.0",
39+
"symfony/debug-bundle": "^5.4 || ^6.0",
40+
"symfony/dotenv": "^5.4 || ^6.0",
4241
"symfony/flex": "^2.2.2",
43-
"symfony/intl": "^5.4",
44-
"symfony/web-profiler-bundle": "^5.4",
42+
"symfony/intl": "^5.4 || ^6.0",
43+
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
4544
"vimeo/psalm": "4.27.0"
4645
},
4746
"config": {

tests/Application/Kernel.php

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
88
use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
99
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
10-
use Symfony\Component\Config\Loader\LoaderInterface;
11-
use Symfony\Component\Config\Resource\FileResource;
12-
use Symfony\Component\DependencyInjection\ContainerBuilder;
1310
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
1411
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
15-
use Symfony\Component\Routing\RouteCollectionBuilder;
12+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
1613

1714
final class Kernel extends BaseKernel
1815
{
@@ -41,24 +38,7 @@ public function registerBundles(): iterable
4138
}
4239
}
4340

44-
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
45-
{
46-
foreach ($this->getConfigurationDirectories() as $confDir) {
47-
$bundlesFile = $confDir . '/bundles.php';
48-
if (false === is_file($bundlesFile)) {
49-
continue;
50-
}
51-
$container->addResource(new FileResource($bundlesFile));
52-
}
53-
54-
$container->setParameter('container.dumper.inline_class_loader', true);
55-
56-
foreach ($this->getConfigurationDirectories() as $confDir) {
57-
$this->loadContainerConfiguration($loader, $confDir);
58-
}
59-
}
60-
61-
protected function configureRoutes(RouteCollectionBuilder $routes): void
41+
protected function configureRoutes(RoutingConfigurator $routes): void
6242
{
6343
foreach ($this->getConfigurationDirectories() as $confDir) {
6444
$this->loadRoutesConfiguration($routes, $confDir);
@@ -79,19 +59,11 @@ private function isTestEnvironment(): bool
7959
return 0 === strpos($this->getEnvironment(), 'test');
8060
}
8161

82-
private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void
83-
{
84-
$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
85-
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
86-
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
87-
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
88-
}
89-
90-
private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void
62+
private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void
9163
{
92-
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
93-
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
94-
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
64+
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS);
65+
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS);
66+
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS);
9567
}
9668

9769
/**

tests/Application/config/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
$_ENV += $env;
1414
} elseif (!class_exists(Dotenv::class)) {
1515
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
16+
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
17+
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
18+
19+
return;
1620
} else {
1721
// load all the .env files
1822
(new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env');

tests/Application/config/packages/security.yaml

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
security:
2-
always_authenticate_before_granting: true
2+
enable_authenticator_manager: true
33
providers:
44
sylius_admin_user_provider:
55
id: sylius.admin_user_provider.email_or_name_based
@@ -10,7 +10,7 @@ security:
1010
sylius_api_shop_user_provider:
1111
id: sylius.shop_user_provider.email_or_name_based
1212

13-
encoders:
13+
password_hashers:
1414
Sylius\Component\User\Model\UserInterface: argon2i
1515
firewalls:
1616
admin:
@@ -26,7 +26,7 @@ security:
2626
default_target_path: sylius_admin_dashboard
2727
use_forward: false
2828
use_referer: true
29-
csrf_token_generator: security.csrf.token_manager
29+
enable_csrf: true
3030
csrf_parameter: _csrf_admin_security_token
3131
csrf_token_id: admin_authenticate
3232
remember_me:
@@ -38,37 +38,32 @@ security:
3838
logout:
3939
path: sylius_admin_logout
4040
target: sylius_admin_login
41-
anonymous: true
4241

4342
new_api_admin_user:
4443
pattern: "%sylius.security.new_api_admin_regex%/.*"
4544
provider: sylius_api_admin_user_provider
4645
stateless: true
47-
anonymous: true
46+
entry_point: jwt
4847
json_login:
4948
check_path: "%sylius.security.new_api_admin_route%/authentication-token"
5049
username_path: email
5150
password_path: password
5251
success_handler: lexik_jwt_authentication.handler.authentication_success
5352
failure_handler: lexik_jwt_authentication.handler.authentication_failure
54-
guard:
55-
authenticators:
56-
- lexik_jwt_authentication.jwt_token_authenticator
53+
jwt: true
5754

5855
new_api_shop_user:
5956
pattern: "%sylius.security.new_api_shop_regex%/.*"
6057
provider: sylius_api_shop_user_provider
6158
stateless: true
62-
anonymous: true
59+
entry_point: jwt
6360
json_login:
6461
check_path: "%sylius.security.new_api_shop_route%/authentication-token"
6562
username_path: email
6663
password_path: password
6764
success_handler: lexik_jwt_authentication.handler.authentication_success
6865
failure_handler: lexik_jwt_authentication.handler.authentication_failure
69-
guard:
70-
authenticators:
71-
- lexik_jwt_authentication.jwt_token_authenticator
66+
jwt: true
7267

7368
shop:
7469
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
@@ -85,7 +80,7 @@ security:
8580
default_target_path: sylius_shop_homepage
8681
use_forward: false
8782
use_referer: true
88-
csrf_token_generator: security.csrf.token_manager
83+
enable_csrf: true
8984
csrf_parameter: _csrf_shop_security_token
9085
csrf_token_id: shop_authenticate
9186
remember_me:
@@ -95,10 +90,8 @@ security:
9590
remember_me_parameter: _remember_me
9691
logout:
9792
path: sylius_shop_logout
98-
target: sylius_shop_login
93+
target: sylius_shop_homepage
9994
invalidate_session: false
100-
success_handler: sylius.handler.shop_user_logout
101-
anonymous: true
10295

10396
dev:
10497
pattern: ^/(_(profiler|wdt)|css|images|js)/
@@ -109,22 +102,23 @@ security:
109102
security: false
110103

111104
access_control:
112-
- { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
105+
- { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
113106
- { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS }
114-
- { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
107+
- { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] }
115108
- { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS }
116109

117-
- { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
118-
- { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
110+
- { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS }
111+
- { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS }
119112

120-
- { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY }
121-
- { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY }
113+
- { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS }
114+
- { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS }
122115

123116
- { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS }
124117
- { path: "%sylius.security.shop_regex%/account", role: ROLE_USER }
125118

119+
- { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS }
126120
- { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
127-
- { path: "%sylius.security.new_api_admin_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY }
121+
- { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS }
128122
- { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER }
129-
- { path: "%sylius.security.new_api_shop_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY }
130-
- { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY }
123+
- { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS }
124+
- { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS }

tests/Application/config/packages/security_checker.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
framework:
22
test: ~
33
session:
4-
storage_id: session.storage.mock_file
4+
storage_factory_id: session.storage.factory.mock_file
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
security:
2-
encoders:
3-
sha512: sha512
2+
password_hashers:
3+
Sylius\Component\User\Model\UserInterface:
4+
algorithm: argon2i
5+
time_cost: 3
6+
memory_cost: 10
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
framework:
2-
test: ~
3-
session:
4-
storage_id: session.storage.mock_file
1+
imports:
2+
- { resource: ../test/framework.yaml }
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
security:
2-
encoders:
3-
sha512: sha512
1+
imports:
2+
- { resource: ../test/security.yaml }

0 commit comments

Comments
 (0)