@@ -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,55 @@ 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+ *
117+ * @throws \Exception
118+ */
119+ private function registerServices (ContainerBuilder $ container , $ config )
120+ {
121+ if ($ config ['annotation ' ]['enabled ' ]) {
122+ $ this ->verifyDoctrineBridgeExists ('annotation ' );
123+ $ container ->register ('cache.service.annotation ' , DoctrineCacheBridge::class)
124+ ->setFactory ([DoctrineBridgeFactory::class, 'get ' ])
125+ ->addArgument (new Reference ($ config ['annotation ' ]['service_id ' ]))
126+ ->addArgument ($ config ['annotation ' ])
127+ ->addArgument ('annotation ' );
128+ }
129+
130+ if ($ config ['serializer ' ]['enabled ' ]) {
131+ $ this ->verifyDoctrineBridgeExists ('serializer ' );
132+ $ container ->register ('cache.service.serializer ' , DoctrineCacheBridge::class)
133+ ->setFactory ([DoctrineBridgeFactory::class, 'get ' ])
134+ ->addArgument (new Reference ($ config ['serializer ' ]['service_id ' ]))
135+ ->addArgument ($ config ['serializer ' ])
136+ ->addArgument ('serializer ' );
137+ }
138+
139+ if ($ config ['validation ' ]['enabled ' ]) {
140+ $ container ->register ('cache.service.validation ' , SymfonyValidatorBridge::class)
141+ ->setFactory ([ValidationFactory::class, 'get ' ])
142+ ->addArgument (new Reference ($ config ['validation ' ]['service_id ' ]))
143+ ->addArgument ($ config ['validation ' ]);
144+ }
145+
146+ if ($ config ['session ' ]['enabled ' ]) {
147+ $ container ->register ('cache.service.session ' , Psr6SessionHandler::class)
148+ ->setFactory ([SessionHandlerFactory::class, 'get ' ])
149+ ->addArgument (new Reference ($ config ['session ' ]['service_id ' ]))
150+ ->addArgument ($ config ['session ' ]);
151+ }
152+
153+ if ($ config ['router ' ]['enabled ' ]) {
154+ $ container ->register ('cache.service.router ' , CachingRouter::class)
155+ ->setDecoratedService ('router ' , null , 10 )
156+ ->addArgument (new Reference ($ config ['router ' ]['service_id ' ]))
157+ ->addArgument (new Reference ('cache.service.router.inner ' ))
158+ ->addArgument ($ config ['router ' ]);
159+ }
160+ }
146161}
0 commit comments