File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed
src/DependencyInjection/Compiler
tests/DependencyInjection/Compiler Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 14
14
15
15
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
16
16
use Symfony \Component \DependencyInjection \ContainerBuilder ;
17
+ use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
17
18
18
19
/**
19
20
* Makes services public that we need to retrieve directly.
@@ -25,8 +26,27 @@ class MakeServicesPublicPass implements CompilerPassInterface
25
26
*/
26
27
public function process (ContainerBuilder $ container ): void
27
28
{
28
- if ($ container ->hasDefinition ('security.firewall.map ' )) {
29
-
8000
$ container ->getDefinition ('security.firewall.map ' )->setPublic (true );
29
+ $ services = [
30
+ 'assets.packages ' ,
31
+ 'database_connection ' ,
32
+ 'doctrine.dbal.default_connection ' ,
33
+ 'fragment.handler ' ,
34
+ 'lexik_maintenance.driver.factory ' ,
35
+ 'monolog.logger.contao ' ,
36
+ 'security.firewall.map ' ,
37
+ 'security.logout_url_generator ' ,
38
+ 'swiftmailer.mailer '
39
+ ];
40
+
41
+ foreach ($ services as $ service ) {
42
+ // Uses findDefinition instead of hasDefinition/getDefinition
43
+ // as hasDefinition does not check aliased services
44
+ try {
45
+ $ definition = $ container ->findDefinition ($ service );
46
+ $ definition ->setPublic (true );
47
+ } catch (ServiceNotFoundException $ exception ) {
48
+ continue ;
49
+ }
30
50
}
31
51
}
32
- }
52
+ }
Original file line number Diff line number Diff line change @@ -29,11 +29,23 @@ public function testCanBeInstantiated(): void
29
29
public function testMakesTheServicesPublic (): void
30
30
{
31
31
$ container = new ContainerBuilder ();
32
- $ container ->setDefinition ('security.firewall.map ' , new Definition ());
32
+ $ container ->setDefinition ('security.firewall.map ' , ( new Definition ())-> setPublic ( false ));
33
33
34
34
$ pass = new MakeServicesPublicPass ();
35
35
$ pass ->process ($ container );
36
36
37
37
$ this ->assertTrue ($ container ->getDefinition ('security.firewall.map ' )->isPublic ());
38
38
}
39
+
40
+ public function testMakesAliasedServicesPublic (): void
41
+ {
42
+ $ container = new ContainerBuilder ();
43
+ $ container ->setDefinition ('contao.fragment.handler ' , (new Definition ())->setPublic (false ));
44
+ $ container ->setAlias ('fragment.handler ' , 'contao.fragment.handler ' );
45
+
46
+ $ pass = new MakeServicesPublicPass ();
47
+ $ pass ->process ($ container );
48
+
49
+ $ this ->assertTrue ($ container ->getDefinition ('contao.fragment.handler ' )->isPublic ());
50
+ }
39
51
}
You can’t perform that action at this time.
0 commit comments