@@ -84,19 +84,13 @@ public function load(array $configs, ContainerBuilder $container)
8484 $ loader ->load ('cache_manager.xml ' );
8585 }
8686
87- $ container ->setParameter ($ this ->getAlias ().'.compiler_pass.tag_annotations ' , $ config ['tags ' ]['enabled ' ]);
8887 if ($ config ['tags ' ]['enabled ' ]) {
89- // true or auto
90- $ container ->setParameter ($ this ->getAlias ().'.tag_handler.header ' , $ config ['tags ' ]['header ' ]);
91- $ loader ->load ('tag_listener.xml ' );
92- if (!empty ($ config ['tags ' ]['rules ' ])) {
93- $ this ->loadTagRules ($ container , $ config ['tags ' ]['rules ' ]);
94- }
95-
96- $ tagsHeader = $ config ['tags ' ]['header ' ];
97- $ container ->getDefinition ($ this ->getAlias ().'.cache_manager ' )
98- ->addMethodCall ('setTagsHeader ' , array ($ tagsHeader ))
99- ;
88+ $ this ->loadCacheTagging (
89+ $ container ,
90+ $ loader ,
91+ $ config ['tags ' ],
92+ $ this ->getDefaultProxyClient ($ config ['proxy_client ' ])
93+ );
10094 }
10195
10296 if ($ config ['invalidation ' ]['enabled ' ]) {
@@ -302,6 +296,30 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader,
302296 }
303297 }
304298
299+ private function loadCacheTagging (ContainerBuilder $ container , XmlFileLoader $ loader , array $ config , $ client )
300+ {
301+ if ('auto ' === $ config ['enabled ' ] && 'varnish ' !== $ client ) {
302+ $ container ->setParameter ($ this ->getAlias ().'.compiler_pass.tag_annotations ' , false );
303+
304+ return ;
305+ }
306+ if ('varnish ' !== $ client ) {
307+ throw new InvalidConfigurationException (sprintf ('You can not enable cache tagging with %s ' , $ client ));
308+ }
309+
310+ $ container ->setParameter ($ this ->getAlias ().'.compiler_pass.tag_annotations ' , true );
311+ $ container ->setParameter ($ this ->getAlias ().'.tag_handler.header ' , $ config ['header ' ]);
312+ $ loader ->load ('tag_listener.xml ' );
313+ if (!empty ($ config ['rules ' ])) {
314+ $ this ->loadTagRules ($ container , $ config ['rules ' ]);
315+ }
316+
317+ $ tagsHeader = $ config ['header ' ];
318+ $ container ->getDefinition ($ this ->getAlias ().'.cache_manager ' )
319+ ->addMethodCall ('setTagsHeader ' , array ($ tagsHeader ))
320+ ;
321+ }
322+
305323 private function loadTest (ContainerBuilder $ container , XmlFileLoader $ loader , array $ config )
306324 {
307325 $ container ->setParameter ($ this ->getAlias ().'.test.cache_header ' , $ config ['cache_header ' ]);
0 commit comments