@@ -32,7 +32,7 @@ class DoctrineAdapterExtension extends Extension
3232 * @type array
3333 */
3434 protected static $ types = [
35- 'memcache ' => [
35+ 'memcache ' => [
3636 'class ' => 'Memcache ' ,
3737 'connect ' => 'addServer ' ,
3838 'port ' => 11211 ,
@@ -42,7 +42,7 @@ class DoctrineAdapterExtension extends Extension
4242 'connect ' => 'addServer ' ,
4343 'port ' => 11211 ,
4444 ],
45- 'redis ' => [
45+ 'redis ' => [
4646 'class ' => 'Redis ' ,
4747 'connect ' => 'connect ' ,
4848 'port ' => 6379 ,
@@ -77,7 +77,12 @@ protected function process(ContainerBuilder $container)
7777 {
7878 $ providers = $ container ->getParameter ('cache_adapter_doctrine.providers ' );
7979
80+ $ first = isset ($ providers ['default ' ]) ? 'default ' : null ;
8081 foreach ($ providers as $ name => $ provider ) {
82+ if ($ first === null ) {
83+ $ first = $ name ;
84+ }
85+
8186 $ classParameter = sprintf ('cache.doctrine_adapter.%s.class ' , $ provider ['type ' ]);
8287 $ doctrineServiceId = sprintf ('cache.doctrine_adapter.doctrine_service.%s ' , $ provider ['type ' ]);
8388 if (!$ container ->hasParameter ($ classParameter )) {
@@ -94,6 +99,8 @@ protected function process(ContainerBuilder $container)
9499 $ this ->createDoctrineCacheDefinition ($ container , $ doctrineServiceId , $ doctrineClass , $ name , $ provider );
95100 $ this ->createPsr7CompliantService ($ container , $ doctrineServiceId , $ name );
96101 }
102+
103+ $ container ->setAlias ('cache ' , 'cache.doctrine_adapter.provider. ' .$ first );
97104 }
98105
99106 /**
@@ -105,8 +112,13 @@ protected function process(ContainerBuilder $container)
105112 * @param string $name
106113 * @param array $provider
107114 */
108- protected function createDoctrineCacheDefinition (ContainerBuilder $ container , $ doctrineServiceId , $ doctrineClass , $ name , array $ provider )
109- {
115+ protected function createDoctrineCacheDefinition (
116+ ContainerBuilder $ container ,
117+ $ doctrineServiceId ,
118+ $ doctrineClass ,
119+ $ name ,
120+ array $ provider
121+ ) {
110122 $ namespace = is_null ($ provider ['namespace ' ]) ? $ name : $ provider ['namespace ' ];
111123
112124 // Create a service for the requested doctrine cache
@@ -145,8 +157,9 @@ protected function createDoctrineCacheDefinition(ContainerBuilder $container, $d
145157 case 'sqlite ' :
146158 case 'riak ' :
147159 case 'chain ' :
148- throw new \InvalidArgumentException (sprintf ('The cache provider type "%s" is not yet implemented. ' , $ type ));
149- break ;
160+ throw new \InvalidArgumentException (
161+ sprintf ('The cache provider type "%s" is not yet implemented. ' , $ type )
162+ );
150163 }
151164
152165 // Add the definition to the container
@@ -177,7 +190,7 @@ protected function createPsr7CompliantService(ContainerBuilder $container, $doct
177190 /**
178191 * Creates a provider to the Doctrine cache provider.
179192 *
180- * @param $type
193+ * @param $type
181194 * @param array $provider
182195 *
183196 * @return Definition
@@ -245,7 +258,7 @@ public function getAlias()
245258
246259 /**
247260 * @param array $provider
248- * @param $helperDefinition
261+ * @param $helperDefinition
249262 *
250263 * @return array
251264 */
0 commit comments