File tree 3 files changed +45
-18
lines changed
src/Symfony/Bundle/FrameworkBundle
DependencyInjection/Compiler
3 files changed +45
-18
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
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
+ namespace Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler ;
13
+
14
+ use Symfony \Component \Cache \Adapter \AbstractAdapter ;
15
+ use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
16
+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
17
+ use Symfony \Component \DependencyInjection \Reference ;
18
+
19
+ final class CacheAnnotationsMonologInjectorPass implements CompilerPassInterface
20
+ {
21
+ /**
22
+ * {@inheritdoc}
23
+ */
24
+ public function process (ContainerBuilder $ container )
25
+ {
26
+ if (!($ container ->hasDefinition ('cache.annotations ' ) || $ container ->hasAlias ('cache.annotations ' ))) {
27
+ return ;
28
+ }
29
+ $ factory = array (AbstractAdapter::class, 'createSystemCache ' );
30
+ $ annotationsPool = $ container ->findDefinition ('cache.annotations ' );
31
+ if ($ factory !== $ annotationsPool ->getFactory () || 4 !== count ($ annotationsPool ->getArguments ())) {
32
+ return ;
33
+ }
34
+ if ($ container ->has ('monolog.logger.cache ' )) {
35
+ $ annotationsPool ->addArgument (new Reference ('monolog.logger.cache ' ));
36
+ } elseif ($ container ->hasDefinition ('cache.system ' )) {
37
+ $ systemPool = $ container ->getDefinition ('cache.system ' );
38
+ if ($ factory === $ systemPool ->getFactory () && 5 <= count ($ systemArgs = $ systemPool ->getArguments ())) {
39
+ $ annotationsPool ->addArgument ($ systemArgs [4 ]);
40
+ }
41
+ }
42
+ }
43
+ }
Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler ;
13
13
14
- use Symfony \Component \Cache \Adapter \AbstractAdapter ;
15
14
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
16
15
use Symfony \Component \DependencyInjection \ContainerBuilder ;
17
16
use Symfony \Component \DependencyInjection \Reference ;
@@ -39,22 +38,5 @@ public function process(ContainerBuilder $container)
39
38
}
40
39
}
41
40
}
42
-
43
- if (!$ container ->has ('cache.annotations ' )) {
44
- return ;
45
- }
46
- $ factory = array (AbstractAdapter::class, 'createSystemCache ' );
47
- $ annotationsPool = $ container ->getDefinition ('cache.annotations ' );
48
- if ($ factory !== $ annotationsPool ->getFactory () || 4 !== count ($ annotationsPool ->getArguments ())) {
49
- return ;
50
- }
51
- if ($ container ->has ('monolog.logger.cache ' )) {
52
- $ annotationsPool ->addArgument (new Reference ('monolog.logger.cache ' ));
53
- } elseif ($ container ->has ('cache.system ' )) {
54
- $ systemPool = $ container ->getDefinition ('cache.system ' );
55
- if ($ factory === $ systemPool ->getFactory () && 5 <= count ($ systemArgs = $ systemPool ->getArguments ())) {
56
- $ annotationsPool ->addArgument ($ systemArgs [4 ]);
57
- }
58
- }
59
41
}
60
42
}
Original file line number Diff line number Diff line change 15
15
use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \AddDebugLogProcessorPass ;
16
16
use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \AddValidatorInitializersPass ;
17
17
use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \AddConsoleCommandPass ;
18
+ use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \CacheAnnotationsMonologInjectorPass ;
18
19
use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \CachePoolPass ;
19
20
use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \CachePoolClearerPass ;
20
21
use Symfony \Bundle \FrameworkBundle \DependencyInjection \Compiler \ControllerArgumentValueResolverPass ;
@@ -96,6 +97,7 @@ public function build(ContainerBuilder $container)
96
97
$ container ->addCompilerPass (new CachePoolPass (), PassConfig::TYPE_BEFORE_OPTIMIZATION , 32 );
97
98
$ container ->addCompilerPass (new ValidateWorkflowsPass ());
98
99
$ container ->addCompilerPass (new CachePoolClearerPass (), PassConfig::TYPE_AFTER_REMOVING );
100
+ $ container ->addCompilerPass (new CacheAnnotationsMonologInjectorPass (), PassConfig::TYPE_BEFORE_REMOVING , 32 );
99
101
100
102
if ($ container ->getParameter ('kernel.debug ' )) {
101
103
$ container ->addCompilerPass (new AddDebugLogProcessorPass (), PassConfig::TYPE_BEFORE_OPTIMIZATION , -32 );
You can’t perform that action at this time.
0 commit comments