File tree 6 files changed +37
-11
lines changed
DependencyInjection/Compiler
Tests/DependencyInjection
6 files changed +37
-11
lines changed Original file line number Diff line number Diff line change 24
24
*/
25
25
class AddCacheClearerPass extends BaseAddCacheClearerPass
26
26
{
27
+ public function __construct ()
28
+ {
29
+ parent ::__construct ('cache_clearer ' , 'kernel.cache_clearer ' );
30
+ }
27
31
}
Original file line number Diff line number Diff line change 24
24
*/
25
25
class AddCacheWarmerPass extends BaseAddCacheWarmerPass
26
26
{
27
+ public function __construct ()
28
+ {
29
+ parent ::__construct ('cache_warmer ' , 'kernel.cache_warmer ' );
30
+ }
27
31
}
Original file line number Diff line number Diff line change @@ -82,8 +82,8 @@ public function build(ContainerBuilder $container)
82
82
$ container ->addCompilerPass (new FormPass ());
83
83
$ container ->addCompilerPass (new TranslatorPass ());
84
84
$ container ->addCompilerPass (new LoggingTranslatorPass ());
85
- $ container ->addCompilerPass (new AddCacheWarmerPass ());
86
- $ container ->addCompilerPass (new AddCacheClearerPass ());
85
+ $ container ->addCompilerPass (new AddCacheWarmerPass (' cache_warmer ' , ' kernel.cache_warmer ' ));
86
+ $ container ->addCompilerPass (new AddCacheClearerPass (' cache_clearer ' , ' kernel.cache_clearer ' ));
87
87
$ container ->addCompilerPass (new AddExpressionLanguageProvidersPass ());
88
88
$ container ->addCompilerPass (new TranslationExtractorPass ());
89
89
$ container ->addCompilerPass (new TranslationDumperPass ());
Original file line number Diff line number Diff line change 22
22
*/
23
23
class AddCacheClearerPass implements CompilerPassInterface
24
24
{
25
+ private $ tag ;
26
+ private $ serviceName ;
27
+
28
+ public function __construct ($ serviceName , $ tag )
29
+ {
30
+ $ this ->serviceName = $ serviceName ;
31
+ $ this ->tag = $ tag ;
32
+ }
33
+
25
34
/**
26
35
* {@inheritdoc}
27
36
*/
28
37
public function process (ContainerBuilder $ container )
29
38
{
30
- if (!$ container ->hasDefinition (' cache_clearer ' )) {
39
+ if (!$ container ->hasDefinition ($ this -> serviceName )) {
31
40
return ;
32
41
}
33
42
34
43
$ clearers = array ();
35
- foreach ($ container ->findTaggedServiceIds (' kernel.cache_clearer ' ) as $ id => $ attributes ) {
44
+ foreach ($ container ->findTaggedServiceIds ($ this -> tag ) as $ id => $ attributes ) {
36
45
$ clearers [] = new Reference ($ id );
37
46
}
38
47
39
- $ container ->getDefinition (' cache_clearer ' )->replaceArgument (0 , $ clearers );
48
+ $ container ->getDefinition ($ this -> serviceName )->replaceArgument (0 , $ clearers );
40
49
}
41
50
}
Original file line number Diff line number Diff line change @@ -24,21 +24,30 @@ class AddCacheWarmerPass implements CompilerPassInterface
24
24
{
25
25
use PriorityTaggedServiceTrait;
26
26
27
+ private $ tag ;
28
+ private $ serviceName ;
29
+
30
+ public function __construct ($ serviceName , $ tag )
31
+ {
32
+ $ this ->serviceName = $ serviceName ;
33
+ $ this ->tag = $ tag ;
34
+ }
35
+
27
36
/**
28
37
* {@inheritdoc}
29
38
*/
30
39
public function process (ContainerBuilder $ container )
31
40
{
32
- if (!$ container ->hasDefinition (' cache_warmer ' )) {
41
+ if (!$ container ->hasDefinition ($ this -> serviceName )) {
33
42
return ;
34
43
}
35
44
36
- $ warmers = $ this ->findAndSortTaggedServices (' kernel.cache_warmer ' , $ container );
45
+ $ warmers = $ this ->findAndSortTaggedServices ($ this -> tag , $ container );
37
46
38
47
if (empty ($ warmers )) {
39
48
return ;
40
49
}
41
50
42
- $ container ->getDefinition (' cache_warmer ' )->replaceArgument (0 , $ warmers );
51
+ $ container ->getDefinition ($ this -> serviceName )->replaceArgument (0 , $ warmers );
43
52
}
44
53
}
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder()
50
50
new Reference ('my_cache_warmer_service3 ' ),
51
51
));
52
52
53
- $ addCacheWarmerPass = new AddCacheWarmerPass ();
53
+ $ addCacheWarmerPass = new AddCacheWarmerPass (' cache_warmer ' , ' kernel.cache_warmer ' );
54
54
$ addCacheWarmerPass ->process ($ container );
55
55
}
56
56
@@ -70,7 +70,7 @@ public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
70
70
->will ($ this ->returnValue (false ));
71
71
$ definition ->expects ($ this ->never ())->method ('replaceArgument ' );
72
72
73
- $ addCacheWarmerPass = new AddCacheWarmerPass ();
73
+ $ addCacheWarmerPass = new AddCacheWarmerPass (' cache_warmer ' , ' kernel.cache_warmer ' );
74
74
$ addCacheWarmerPass ->process ($ container );
75
75
}
76
76
@@ -93,7 +93,7 @@ public function testThatCacheWarmersMightBeNotDefined()
93
93
94
94
$ definition ->expects ($ this ->never ())->method ('replaceArgument ' );
95
95
96
- $ addCacheWarmerPass = new AddCacheWarmerPass ();
96
+ $ addCacheWarmerPass = new AddCacheWarmerPass (' cache_warmer ' , ' kernel.cache_warmer ' );
97
97
$ addCacheWarmerPass ->process ($ container );
98
98
}
99
99
}
You can’t perform that action at this time.
0 commit comments