Skip to content

Commit 895f703

Browse files
committed
Symfony 6 config compatibility
1 parent 0764e3c commit 895f703

File tree

4 files changed

+57
-28
lines changed

4 files changed

+57
-28
lines changed

resources/config/default.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
$loader->import('dist/monolog.yml');
3333
}
3434
$loader->import('dist/doctrine.yml');
35-
$loader->import('dist/security.yml');
3635
$loader->import('dist/framework.php');
36+
$loader->import('dist/security.php');

resources/config/dist/framework.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
$config = [
1818
'secret' => 'test',
1919
'test' => null,
20-
'session' => [
21-
'storage_id' => 'session.storage.filesystem',
22-
],
2320
'form' => true,
2421
'validation' => [
2522
'enabled' => true,
@@ -34,6 +31,14 @@
3431
],
3532
];
3633

34+
if (interface_exists(\Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface::class)) {
35+
// Symfony 5.3+
36+
$config = array_merge($config, ['session' => ['storage_factory_id' => 'session.storage.factory.mock_file']]);
37+
} else {
38+
// Symfony <5.3
39+
$config = array_merge($config, ['session' => ['storage_id' => 'session.storage.filesystem']]);
40+
}
41+
3742
$container->loadFromExtension('framework', $config);
3843

3944
$container->loadFromExtension('twig', [

resources/config/dist/security.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2017 Symfony CMF
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+
$config = [
13+
'encoders' => [
14+
'Symfony\Component\Security\Core\User\User' => 'plaintext',
15+
],
16+
'role_hierarchy' => [
17+
'ROLE_ADMIN' => 'ROLE_USER',
18+
'ROLE_SUPER_ADMIN' => ['ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'],
19+
],
20+
'providers' => [
21+
'in_memory' => [
22+
'memory' => [
23+
'users' => [
24+
'admin' => ['password' => 'adminpass', 'roles' => ['ROLE_ADMIN']],
25+
],
26+
],
27+
],
28+
],
29+
'firewalls' => [
30+
'dev' => [
31+
'pattern' => '^/(_(profiler|wdt)|css|images|js)/',
32+
'security' => false,
33+
],
34+
'main' => [
35+
'pattern' => '^/',
36+
'http_basic' => [
37+
'realm' => 'Secured Demo Area',
38+
],
39+
],
40+
],
41+
];
42+
43+
if (class_exists(\Symfony\Component\Security\Core\Authentication\Provider\AnonymousAuthenticationProvider::class)) {
44+
// Symfony <=5.4
45+
$config = array_merge($config, ['firewall' => ['main' => ['anonymous' => null]]]);
46+
}
47+
48+
$container->loadFromExtension('security', $config);

resources/config/dist/security.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)