1111
1212namespace Cache \CacheBundle \DependencyInjection ;
1313
14- use Symfony \ Component \ Config \ FileLocator ;
14+ use Cache \ CacheBundle \ DataCollector \ CacheDataCollector ;
1515use Symfony \Component \DependencyInjection \ContainerBuilder ;
16- use Symfony \Component \DependencyInjection \Loader ;
1716use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
1817
1918/**
@@ -31,40 +30,20 @@ class CacheExtension extends Extension
3130 */
3231 public function load (array $ configs , ContainerBuilder $ container )
3332 {
34- $ configuration = new Configuration ($ container ->getParameter ('kernel.debug ' ));
35- $ config = $ this ->processConfiguration ($ configuration , $ configs );
36-
37- $ loader = new Loader \YamlFileLoader ($ container , new FileLocator (__DIR__ . '/../Resources/config ' ));
38- $ loader ->load ('services.yml ' );
33+ $ config = $ this ->processConfiguration (new Configuration (), $ configs );
3934
4035 if ($ container ->getParameter ('kernel.debug ' )) {
41- $ loader ->load ('collector.yml ' );
42- }
43-
44- $ container ->setParameter ($ this ->getAlias () . '.instance ' , $ config ['instances ' ]);
45- new Builder \ServiceBuilder ($ container );
46-
47- if ($ config ['router ' ]['enabled ' ]) {
48- $ container ->setParameter ($ this ->getAlias () . '.router ' , $ config ['router ' ]);
49- }
50-
51- if ($ config ['session ' ]['enabled ' ]) {
52- $ container ->setParameter ($ this ->getAlias () . '.session ' , $ config ['session ' ]);
36+ $ container ->register ('data_collector.cache ' , CacheDataCollector::class)
37+ ->addTag ('data_collector ' , ['template ' => CacheDataCollector::TEMPLATE , 'id ' => 'cache ' ]);
5338 }
5439
55- if ($ config ['doctrine ' ]['enabled ' ]) {
56- $ container ->setParameter ($ this ->getAlias () . '.doctrine ' , $ config ['doctrine ' ]);
40+ foreach (['router ' , 'session ' , 'doctrine ' ] as $ section ) {
41+ if ($ container [$ section ]['enabled ' ]) {
42+ $ container ->setParameter ($ this ->getAlias ().'. ' .$ section , $ config [$ section ]);
43+ }
5744 }
5845 }
5946
60- /**
61- * {@inheritDoc}
62- */
63- public function getConfiguration (array $ config , ContainerBuilder $ container )
64- {
65- return new Configuration ($ container ->getParameter ('kernel.debug ' ));
66- }
67-
6847 public function getAlias ()
6948 {
7049 return 'cache ' ;
0 commit comments