@@ -53,57 +53,21 @@ public function load(array $configs, ContainerBuilder $container)
5353 $ this ->verifyDoctrineBridgeExists ('doctrine ' );
5454 }
5555
56- if ($ config ['annotation ' ]['enabled ' ]) {
57- $ this ->verifyDoctrineBridgeExists ('annotation ' );
58- $ container ->register ('cache.service.annotation ' , DoctrineCacheBridge::class)
59- ->setFactory ([DoctrineBridgeFactory::class, 'get ' ])
60- ->addArgument (new Reference ($ config ['annotation ' ]['service_id ' ]))
61- ->addArgument ($ config ['annotation ' ])
62- ->addArgument ('annotation ' );
63- }
64-
65- if ($ config ['serializer ' ]['enabled ' ]) {
66- $ this ->verifyDoctrineBridgeExists ('serializer ' );
67- $ container ->register ('cache.service.serializer ' , DoctrineCacheBridge::class)
68- ->setFactory ([DoctrineBridgeFactory::class, 'get ' ])
69- ->addArgument (new Reference ($ config ['serializer ' ]['service_id ' ]))
70- ->addArgument ($ config ['serializer ' ])
71- ->addArgument ('serializer ' );
72- }
73-
74- if ($ config ['validation ' ]['enabled ' ]) {
75- $ container ->register ('cache.service.validation ' , SymfonyValidatorBridge::class)
76- ->setFactory ([ValidationFactory::class, 'get ' ])
77- ->addArgument (new Reference ($ config ['validation ' ]['service_id ' ]))
78- ->addArgument ($ config ['validation ' ]);
79- }
80-
81- if ($ config ['session ' ]['enabled ' ]) {
82- $ container ->register ('cache.service.session ' , Psr6SessionHandler::class)
83- ->setFactory ([SessionHandlerFactory::class, 'get ' ])
84- ->addArgument (new Reference ($ config ['session ' ]['service_id ' ]))
85- ->addArgument ($ config ['session ' ]);
86- }
87-
88- if ($ config ['router ' ]['enabled ' ]) {
89- $ container ->register ('cache.service.router ' , CachingRouter::class)
90- ->setDecoratedService ('router ' , null , 10 )
91- ->addArgument (new Reference ($ config ['router ' ]['service_id ' ]))
92- ->addArgument (new Reference ('cache.service.router.inner ' ))
93- ->addArgument ($ config ['router ' ]);
94- }
56+ $ this ->registerServices ($ container , $ config );
9557
58+ // Add toolbar and data collector if we are debuging
9659 if ($ container ->getParameter ('kernel.debug ' )) {
9760 $ loader ->load ('data-collector.yml ' );
9861 }
9962
63+ // Get a list of the psr-6 services we are using.
10064 $ serviceIds = [];
10165 $ this ->findServiceIds ($ config , $ serviceIds );
10266 $ container ->setParameter ('cache.provider_service_ids ' , $ serviceIds );
10367 }
10468
10569 /**
106- * Find service ids that we configured.
70+ * Find service ids that we configured. These services should be tagged so we can use them in the debug toolbar.
10771 *
10872 * @param array $config
10973 * @param array $serviceIds
@@ -143,4 +107,54 @@ public function getAlias()
143107 {
144108 return 'cache ' ;
145109 }
110+
111+ /**
112+ * Register services. All service ids will start witn "cache.service.".
113+ *
114+ * @param ContainerBuilder $container
115+ * @param $config
116+ * @throws \Exception
117+ */
118+ private function registerServices (ContainerBuilder $ container , $ config )
119+ {
120+ if ($ config ['annotation ' ]['enabled ' ]) {
121+ $ this ->verifyDoctrineBridgeExists ('annotation ' );
122+ $ container ->register ('cache.service.annotation ' , DoctrineCacheBridge::class)
123+ ->setFactory ([DoctrineBridgeFactory::class, 'get ' ])
124+ ->addArgument (new Reference ($ config ['annotation ' ]['service_id ' ]))
125+ ->addArgument ($ config ['annotation ' ])
126+ ->addArgument ('annotation ' );
127+ }
128+
129+ if ($ config ['serializer ' ]['enabled ' ]) {
130+ $ this ->verifyDoctrineBridgeExists ('serializer ' );
131+ $ container ->register ('cache.service.serializer ' , DoctrineCacheBridge::class)
132+ ->setFactory ([DoctrineBridgeFactory::class, 'get ' ])
133+ ->addArgument (new Reference ($ config ['serializer ' ]['service_id ' ]))
134+ ->addArgument ($ config ['serializer ' ])
135+ ->addArgument ('serializer ' );
136+ }
137+
138+ if ($ config ['validation ' ]['enabled ' ]) {
139+ $ container ->register ('cache.service.validation ' , SymfonyValidatorBridge::class)
140+ ->setFactory ([ValidationFactory::class, 'get ' ])
141+ ->addArgument (new Reference ($ config ['validation ' ]['service_id ' ]))
142+ ->addArgument ($ config ['validation ' ]);
143+ }
144+
145+ if ($ config ['session ' ]['enabled ' ]) {
146+ $ container ->register ('cache.service.session ' , Psr6SessionHandler::class)
147+ ->setFactory ([SessionHandlerFactory::class, 'get ' ])
148+ ->addArgument (new Reference ($ config ['session ' ]['service_id ' ]))
149+ ->addArgument ($ config ['session ' ]);
150+ }
151+
152+ if ($ config ['router ' ]['enabled ' ]) {
153+ $ container ->register ('cache.service.router ' , CachingRouter::class)
154+ ->setDecoratedService ('router ' , null , 10 )
155+ ->addArgument (new Reference ($ config ['router ' ]['service_id ' ]))
156+ ->addArgument (new Reference ('cache.service.router.inner ' ))
157+ ->addArgument ($ config ['router ' ]);
158+ }
159+ }
146160}
0 commit comments