File tree Expand file tree Collapse file tree
DependencyInjection/Compiler Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace EzSystems \PlatformHttpCacheBundle \DependencyInjection \Compiler ;
4+
5+ use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
6+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
7+
8+ class PurgeTypeSettingsPass implements CompilerPassInterface
9+ {
10+ public function process (ContainerBuilder $ container )
11+ {
12+ $ purgeType = $ container ->getParameter ('ezpublish.http_cache.purge_type ' );
13+ $ purgeService = null ;
14+
15+ $ purgeClientServiceIds = $ container ->findTaggedServiceIds ('ezplatform.http_cache.purge_client ' );
16+ foreach ($ purgeClientServiceIds as $ purgeClientServiceId => $ attributes ) {
17+ $ hasPurgeTypeAttribute = false ;
18+ foreach ($ attributes as $ attribute ) {
19+ if (array_key_exists ('purge_type ' , $ attribute )) {
20+ $ hasPurgeTypeAttribute = true ;
21+ if ($ purgeType === $ attribute ['purge_type ' ]) {
22+ $ purgeService = $ purgeClientServiceId ;
23+ break ;
24+ }
25+ }
26+ }
27+ if (!$ hasPurgeTypeAttribute ) {
28+ throw new \InvalidArgumentException ("Missing attribute 'purge_type' in tagged service ' $ purgeClientServiceId'. " );
29+ }
30+ }
31+
32+ if ($ purgeService === null ) {
33+ throw new \InvalidArgumentException ("No driver found being able to handle purge_type ' $ purgeType'. " );
34+ }
35+
36+ $ container ->setAlias ('ezplatform.http_cache.purge_client ' , $ purgeService );
37+ }
38+ }
Original file line number Diff line number Diff line change 44
55use EzSystems \PlatformHttpCacheBundle \DependencyInjection \Compiler \ResponseTaggersPass ;
66use EzSystems \PlatformHttpCacheBundle \DependencyInjection \Compiler \KernelPass ;
7+ use EzSystems \PlatformHttpCacheBundle \DependencyInjection \Compiler \PurgeTypeSettingsPass ;
78use Symfony \Component \DependencyInjection \ContainerBuilder ;
89use Symfony \Component \HttpKernel \Bundle \Bundle ;
910
@@ -15,5 +16,6 @@ public function build(ContainerBuilder $container)
1516
1617 $ container ->addCompilerPass (new ResponseTaggersPass ());
1718 $ container ->addCompilerPass (new KernelPass ());
19+ $ container ->addCompilerPass (new PurgeTypeSettingsPass ());
1820 }
1921}
Original file line number Diff line number Diff line change @@ -13,10 +13,14 @@ services:
1313 ezplatform.http_cache.purge_client.fos :
1414 class : EzSystems\PlatformHttpCacheBundle\PurgeClient\FOSPurgeClient
1515 arguments : ["@ezplatform.http_cache.cache_manager"]
16+ tags :
17+ - {name: ezplatform.http_cache.purge_client, purge_type: http}
1618
1719 ezplatform.http_cache.purge_client.local :
1820 class : EzSystems\PlatformHttpCacheBundle\PurgeClient\LocalPurgeClient
1921 arguments : ["@ezplatform.http_cache.store"]
22+ tags :
23+ - {name: ezplatform.http_cache.purge_client, purge_type: local}
2024
2125 ezplatform.http_cache.store :
2226 alias : ezplatform.http_cache.tag_aware_store
You can’t perform that action at this time.
0 commit comments