1515class CacheCompilerPass implements CompilerPassInterface
1616{
1717 /**
18- * You can modify the container here before it is dumped to PHP code.
19- *
20- * @param ContainerBuilder $container
21- *
22- * @api
18+ * @inheritDoc
2319 */
2420 public function process (ContainerBuilder $ container )
2521 {
@@ -32,18 +28,22 @@ public function process(ContainerBuilder $container)
3228 )
3329 );
3430
35-
36- $ this ->proxyServicesToBeCached ($ container );
31+ $ this ->analyzeServicesTobeCached ($ container );
3732 }
3833
3934 /**
40- * @param ContainerBuilder $container
41- * @return array
35+ * @param ContainerBuilder $container
36+ *
37+ * @return void
4238 */
43- protected function proxyServicesToBeCached (ContainerBuilder $ container )
39+ protected function analyzeServicesTobeCached (ContainerBuilder $ container )
4440 {
4541 $ annotationReader = new AnnotationReader ();
46- $ servicesToBeCached = [];
42+ $ annotationReaderReference = new Reference ("annotation_reader " );
43+ $ proxyWarmup = $ container ->getDefinition ('emag.cache.warmup ' );
44+ $ cacheProxyFactory = new Reference ('emag.cache.proxy.factory ' );
45+ $ cacheServiceReference = new Reference ($ container ->getParameter ('emag.cache.service ' ));
46+
4747 foreach ($ container ->getDefinitions () as $ serviceId => $ definition ) {
4848 if (!class_exists ($ definition ->getClass ()) || $ this ->isFromIgnoredNamespace ($ container , $ definition ->getClass ())) {
4949 continue ;
@@ -66,24 +66,24 @@ protected function proxyServicesToBeCached(ContainerBuilder $container)
6666 }
6767
6868 $ wrapper = new Definition ($ definition ->getClass ());
69- $ wrapper ->setFactory ([new Reference ('emag.cache.proxy.factory ' ), 'generate ' ]);
70- $ wrapper ->setTags ($ definition ->getTags ());
71- $ wrapper ->setArguments ([$ definition ->getClass (), $ definition ->getArguments ()]);
72- $ wrapper ->setMethodCalls ($ definition ->getMethodCalls ());
73- $ wrapper ->setProperties ($ definition ->getProperties ());
74- $ wrapper ->setProperties ($ definition ->getProperties ());
75- $ wrapper ->addMethodCall ('setReaderForCacheMethod ' , [new Reference ("annotation_reader " )]);
76- $ wrapper ->addMethodCall ('setCacheServiceForMethod ' , [new Reference ($ container ->getParameter ('cache.service ' ))]);
77- $ container ->getDefinition ('emag.cache.warmup ' )->addMethodCall ('addClassToGenerate ' , [$ definition ->getClass ()]);
69+ $ wrapper
70+ ->setFactory ([$ cacheProxyFactory , 'generate ' ])
71+ ->setTags ($ definition ->getTags ())
72+ ->setArguments ([$ definition ->getClass (), $ definition ->getArguments ()])
73+ ->setMethodCalls ($ definition ->getMethodCalls ())
74+ ->setProperties ($ definition ->getProperties ())
75+ ->setProperties ($ definition ->getProperties ())
76+ ->addMethodCall ('setReaderForCacheMethod ' , [$ annotationReaderReference ])
77+ ->addMethodCall ('setCacheServiceForMethod ' , [$ cacheServiceReference ])
78+ ;
7879
80+ $ proxyWarmup ->addMethodCall ('addClassToGenerate ' , [$ definition ->getClass ()]);
7981
8082 $ container ->setDefinition ($ serviceId , $ wrapper );
8183 break ;
8284 }
8385 }
8486 }
85-
86- return $ servicesToBeCached ;
8787 }
8888
8989 /**
0 commit comments