@@ -34,31 +34,11 @@ public function load(array $configs, ContainerBuilder $container)
34
34
}
35
35
36
36
if (isset ($ config ['proxy_client ' ])) {
37
- $ container ->setParameter ($ this ->getAlias ().'.invalidators ' , $ config ['invalidators ' ]);
38
37
$ this ->loadProxyClient ($ container , $ loader , $ config ['proxy_client ' ]);
38
+ }
39
39
40
- $ loader ->load ('cache_manager.xml ' );
41
-
42
- if ($ config ['tag_listener ' ]['enabled ' ]) {
43
- // true or auto
44
- if (class_exists ('\Symfony\Component\ExpressionLanguage\ExpressionLanguage ' )) {
45
- $ loader ->load ('tag_listener.xml ' );
46
- } elseif (true === $ config ['tag_listener ' ]['enabled ' ]) {
47
- // silently skip if set to auto
48
- throw new InvalidConfigurationException ('The TagListener requires symfony/expression-language ' );
49
- }
50
- }
51
-
52
- if (version_compare (Kernel::VERSION , '2.4.0 ' , '>= ' )) {
53
- $ container
54
- ->getDefinition ('fos_http_cache.command.invalidate_path ' )
55
- ->addTag ('console.command ' )
56
- ;
57
- }
58
- } elseif (!empty ($ config ['invalidators ' ])) {
59
- throw new InvalidConfigurationException ('You need to configure a proxy client to use the invalidators. ' );
60
- } elseif (true === $ config ['tag_listener ' ]['enabled ' ]) {
61
- throw new InvalidConfigurationException ('You need to configure a proxy client to use the tag listener. ' );
40
+ if ($ config ['cache_manager ' ]['enabled ' ] && isset ($ config ['proxy_client ' ])) {
41
+ $ this ->loadCacheManager ($ container , $ loader , $ config ['cache_manager ' ]);
62
42
}
63
43
64
44
if (!empty ($ config ['rules ' ])) {
@@ -82,9 +62,11 @@ public function load(array $configs, ContainerBuilder $container)
82
62
83
63
/**
84
64
* @param ContainerBuilder $container
85
- * @param $config
65
+ * @param array $config
66
+ *
67
+ * @throws InvalidConfigurationException
86
68
*/
87
- protected function loadRules (ContainerBuilder $ container , $ config )
69
+ protected function loadRules (ContainerBuilder $ container , array $ config )
88
70
{
89
71
foreach ($ config ['rules ' ] as $ rule ) {
90
72
$ match = $ rule ['match ' ];
@@ -112,13 +94,18 @@ protected function loadRules(ContainerBuilder $container, $config)
112
94
$ extraCriteria
113
95
);
114
96
115
- if (isset ($ rule ['tags ' ]) && count ($ rule ['tags ' ])) {
97
+ $ tags = array (
98
+ 'tags ' => $ rule ['tags ' ],
99
+ 'expressions ' => $ rule ['tag_expressions ' ],
100
+ );
101
+ if (count ($ tags ['tags ' ]) || count ($ tags ['expressions ' ])) {
116
102
if (!$ container ->hasDefinition ($ this ->getAlias () . '.event_listener.tag ' )) {
117
103
throw new InvalidConfigurationException ('To configure tags, you need to have the tag event listener enabled, requiring symfony/expression-language ' );
118
104
}
105
+
119
106
$ container
120
107
->getDefinition ($ this ->getAlias () . '.event_listener.tag ' )
121
- ->addMethodCall ('addRule ' , array ($ ruleMatcher , $ rule [ ' tags ' ] ))
108
+ ->addMethodCall ('addRule ' , array ($ ruleMatcher , $ tags ))
122
109
;
123
110
}
124
111
@@ -221,6 +208,37 @@ protected function loadVarnish(ContainerBuilder $container, XmlFileLoader $loade
221
208
$ container ->setParameter ($ this ->getAlias () . '.proxy_client.varnish.base_url ' , $ config ['base_url ' ]);
222
209
}
223
210
211
+ protected function loadCacheManager (ContainerBuilder $ container , XmlFileLoader $ loader , array $ config )
212
+ {
213
+ $ container ->setParameter ($ this ->getAlias ().'.cache_manager.route_invalidators ' , $ config ['route_invalidators ' ]);
214
+
215
+ $ container ->setParameter (
216
+ $ this ->getAlias () . '.cache_manager.additional_status ' ,
217
+ isset ($ config ['additional_status ' ]) ? $ config ['additional_status ' ] : array ()
218
+ );
219
+ $ container ->setParameter (
220
+ $ this ->getAlias () . '.cache_manager.match_response ' ,
221
+ isset ($ config ['match_response ' ]) ? $ config ['match_response ' ] : null
222
+ );
223
+ $ loader ->load ('cache_manager.xml ' );
224
+ if (version_compare (Kernel::VERSION , '2.4.0 ' , '>= ' )) {
225
+ $ container
226
+ ->getDefinition ('fos_http_cache.command.invalidate_path ' )
227
+ ->addTag ('console.command ' )
228
+ ;
229
+ }
230
+
231
+ if ($ config ['tag_listener ' ]['enabled ' ]) {
232
+ // true or auto
233
+ if (class_exists ('\Symfony\Component\ExpressionLanguage\ExpressionLanguage ' )) {
234
+ $ loader ->load ('tag_listener.xml ' );
235
+ } elseif (true === $ config ['tag_listener ' ]['enabled ' ]) {
236
+ // silently skip if set to auto
237
+ throw new InvalidConfigurationException ('The TagListener requires symfony/expression-language ' );
238
+ }
239
+ }
240
+ }
241
+
224
242
private function validateUrl ($ url , $ msg )
225
243
{
226
244
if (false === strpos ($ url , ':// ' )) {
0 commit comments