Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c77a9cc

Browse files
committed
define all commands as services
1 parent 7ae0e4f commit c77a9cc

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function load(array $configs, ContainerBuilder $container)
5959
}
6060

6161
if ($config['cache_manager']['enabled']) {
62-
$this->loadCacheManager($container, $loader, $config['cache_manager']);
62+
$loader->load('cache_manager.xml');
6363
}
6464

6565

@@ -248,17 +248,6 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a
248248
$container->setParameter($this->getAlias() . '.proxy_client.nginx.purge_location', $config['purge_location']);
249249
}
250250

251-
private function loadCacheManager(ContainerBuilder $container, XmlFileLoader $loader, array $config)
252-
{
253-
$loader->load('cache_manager.xml');
254-
if (version_compare(Kernel::VERSION, '2.4.0', '>=')) {
255-
$container
256-
->getDefinition('fos_http_cache.command.invalidate_path')
257-
->addTag('console.command')
258-
;
259-
}
260-
}
261-
262251
private function loadTagRules(ContainerBuilder $container, array $config)
263252
{
264253
$tagDefinition = $container->getDefinition($this->getAlias() . '.event_listener.tag');

Resources/config/cache_manager.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<parameter key="fos_http_cache.cache_manager.class">FOS\HttpCacheBundle\CacheManager</parameter>
99
<parameter key="fos_http_cache.event_listener.log.class">FOS\HttpCache\EventListener\LogSubscriber</parameter>
1010
<parameter key="fos_http_cache.command.invalidate_path.class">FOS\HttpCacheBundle\Command\InvalidatePathCommand</parameter>
11+
<parameter key="fos_http_cache.command.invalidate_regex.class">FOS\HttpCacheBundle\Command\InvalidateRegexCommand</parameter>
12+
<parameter key="fos_http_cache.command.invalidate_tag.class">FOS\HttpCacheBundle\Command\InvalidateTagCommand</parameter>
13+
<parameter key="fos_http_cache.command.refresh_path.class">FOS\HttpCacheBundle\Command\RefreshPathCommand</parameter>
1114
</parameters>
1215

1316
<services>
@@ -26,8 +29,26 @@
2629
<argument type="service" id="logger" />
2730
</service>
2831

32+
<!-- for symfony < 2.4 the command will be instantiated by the framework and the command services are ignored -->
33+
2934
<service id="fos_http_cache.command.invalidate_path" class="%fos_http_cache.command.invalidate_path.class%">
3035
<argument type="service" id="fos_http_cache.cache_manager" />
36+
<tag name="console.command"/>
37+
</service>
38+
39+
<service id="fos_http_cache.command.invalidate_regex" class="%fos_http_cache.command.invalidate_regex.class%">
40+
<argument type="service" id="fos_http_cache.cache_manager" />
41+
<tag name="console.command"/>
42+
</service>
43+
44+
<service id="fos_http_cache.command.invalidate_tag" class="%fos_http_cache.command.invalidate_tag.class%">
45+
<argument type="service" id="fos_http_cache.cache_manager" />
46+
<tag name="console.command"/>
47+
</service>
48+
49+
<service id="fos_http_cache.command.refresh_path" class="%fos_http_cache.command.refresh_path.class%">
50+
<argument type="service" id="fos_http_cache.cache_manager" />
51+
<tag name="console.command"/>
3152
</service>
3253
</services>
3354

0 commit comments

Comments
 (0)