1111
1212namespace Cache \CacheBundle \DependencyInjection ;
1313
14- use Cache \CacheBundle \Cache \LoggingCachePool ;
15- use Cache \CacheBundle \DataCollector \CacheDataCollector ;
14+ use Symfony \Component \Config \FileLocator ;
1615use Symfony \Component \DependencyInjection \ContainerBuilder ;
1716use Symfony \Component \DependencyInjection \Reference ;
1817use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
18+ use Symfony \Component \DependencyInjection \Loader ;
19+
1920
2021/**
21- * Class AequasiCacheExtension
2222 *
2323 * @author Aaron Scherer <aequasi@gmail.com>
24+ * @author Tobias Nyholm <tobias.nyholm@gmail.com>
2425 */
2526class CacheExtension extends Extension
2627{
@@ -34,17 +35,24 @@ public function load(array $configs, ContainerBuilder $container)
3435 {
3536 $ config = $ this ->processConfiguration (new Configuration (), $ configs );
3637
37- if ($ container ->getParameter ('kernel.debug ' )) {
38- $ container ->register ('data_collector.cache ' , CacheDataCollector::class)
39- ->addTag ('data_collector ' , ['template ' => CacheDataCollector::TEMPLATE , 'id ' => 'cache ' ]);
40- }
38+ $ loader = new Loader \YamlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
39+ $ loader ->load ('services.yml ' );
4140
4241 foreach (['router ' , 'session ' , 'doctrine ' ] as $ section ) {
4342 if ($ config [$ section ]['enabled ' ]) {
4443 $ container ->setParameter ('cache. ' .$ section , $ config [$ section ]);
4544 }
4645 }
4746
47+ if ($ config ['router ' ]['enabled ' ]) {
48+ $ container ->getDefinition ('cache.router_listener ' )->replaceArgument (0 , new Reference ($ config ['router ' ]['service_id ' ]));
49+ } else {
50+ $ container ->removeDefinition ('cache.router_listener ' );
51+ }
52+
53+ if (!$ container ->getParameter ('kernel.debug ' )) {
54+ $ container ->removeDefinition ('data_collector.cache ' );
55+ }
4856 }
4957
5058 public function getAlias ()
0 commit comments