11<?php
22
3+ /*
4+ * This file is part of php-cache\doctrine-adapter-bundle package.
5+ *
6+ * (c) 2015-2015 Aaron Scherer <[email protected] > 7+ *
8+ * This source file is subject to the MIT license that is bundled
9+ * with this source code in the file LICENSE.
10+ */
11+
312namespace Cache \Adapter \DoctrineAdapterBundle \DependencyInjection ;
413
14+ use Cache \Doctrine \CachePool ;
15+ use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
516use Symfony \Component \Config \FileLocator ;
617use Symfony \Component \DependencyInjection \ContainerBuilder ;
7- use Symfony \Component \DependencyInjection \Loader ;
8- use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
9- use Symfony \Component \Config \Definition \Exception \InvalidConfigurationException ;
10- use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
1118use Symfony \Component \DependencyInjection \Definition ;
19+ use Symfony \Component \DependencyInjection \Loader ;
1220use Symfony \Component \DependencyInjection \Reference ;
13- use Cache \ Doctrine \ CachePool ;
21+ use Symfony \ Component \ HttpKernel \ DependencyInjection \ Extension ;
1422
1523/**
16- *
1724 * @author Aaron Scherer <[email protected] > 1825 * @author Tobias Nyholm <[email protected] > 1926 */
@@ -22,19 +29,19 @@ class DoctrineAdapterExtension extends Extension
2229 /**
2330 * Array of types, and their options.
2431 *
25- * @var array
32+ * @type array
2633 */
2734 protected static $ types = [
2835 'memcache ' => [
29- 'class ' => 'Memcache ' ,
36+ 'class ' => 'Memcache ' ,
3037 'connect ' => 'addServer ' ,
3138 ],
3239 'memcached ' => [
33- 'class ' => 'Cache\Adapter\DoctrineAdapterBundle\ProviderHelper\Memcached ' ,
40+ 'class ' => 'Cache\Adapter\DoctrineAdapterBundle\ProviderHelper\Memcached ' ,
3441 'connect ' => 'addServer ' ,
3542 ],
3643 'redis ' => [
37- 'class ' => 'Redis ' ,
44+ 'class ' => 'Redis ' ,
3845 'connect ' => 'connect ' ,
3946 ],
4047 ];
@@ -48,7 +55,7 @@ class DoctrineAdapterExtension extends Extension
4855 public function load (array $ configs , ContainerBuilder $ container )
4956 {
5057 $ configuration = new Configuration ();
51- $ config = $ this ->processConfiguration ($ configuration , $ configs );
58+ $ config = $ this ->processConfiguration ($ configuration , $ configs );
5259
5360 $ loader = new Loader \YamlFileLoader ($ container , new FileLocator (__DIR__ .'/../Resources/config ' ));
5461 $ loader ->load ('services.yml ' );
@@ -58,8 +65,6 @@ public function load(array $configs, ContainerBuilder $container)
5865 $ this ->process ($ container );
5966 }
6067
61-
62-
6368 /**
6469 * For each configured provider, build a service.
6570 *
@@ -70,7 +75,7 @@ protected function process(ContainerBuilder $container)
7075 $ providers = $ container ->getParameter ('cache_adapter_doctrine.providers ' );
7176
7277 foreach ($ providers as $ name => $ provider ) {
73- $ classParameter = sprintf ('cache.doctrine_adapter.%s.class ' ,$ provider ['type ' ]);
78+ $ classParameter = sprintf ('cache.doctrine_adapter.%s.class ' , $ provider ['type ' ]);
7479 $ doctrineServiceId = sprintf ('cache.doctrine_adapter.doctrine_service.%s ' , $ provider ['type ' ]);
7580 if (!$ container ->hasParameter ($ classParameter )) {
7681 throw new InvalidConfigurationException (
@@ -88,16 +93,14 @@ protected function process(ContainerBuilder $container)
8893 }
8994 }
9095
91-
92-
9396 /**
9497 * We need to prepare the doctrine cache providers.
9598 *
9699 * @param ContainerBuilder $container
97- * @param string $doctrineServiceId
98- * @param string $doctrineClass
99- * @param string $name
100- * @param array $provider
100+ * @param string $doctrineServiceId
101+ * @param string $doctrineClass
102+ * @param string $name
103+ * @param array $provider
101104 */
102105 protected function createDoctrineCacheDefinition (ContainerBuilder $ container , $ doctrineServiceId , $ doctrineClass , $ name , array $ provider )
103106 {
@@ -117,7 +120,7 @@ protected function createDoctrineCacheDefinition(ContainerBuilder $container, $d
117120 $ providerHelperServiceId = $ provider ['id ' ];
118121 } else {
119122 // Create a new cache provider if none is defined
120- $ providerHelperServiceId = sprintf ('cache_adapter_doctrine.provider.%s.helper ' , $ name );
123+ $ providerHelperServiceId = sprintf ('cache_adapter_doctrine.provider.%s.helper ' , $ name );
121124 $ providerHelperDefinition = $ this ->createProviderHelperDefinition ($ type , $ provider );
122125 $ container ->setDefinition ($ providerHelperServiceId , $ providerHelperDefinition );
123126 }
@@ -151,8 +154,8 @@ protected function createDoctrineCacheDefinition(ContainerBuilder $container, $d
151154 * Make sure to create a PRS-6 service that wraps the doctrine service.
152155 *
153156 * @param ContainerBuilder $container
154- * @param string $doctrineServiceId
155- * @param string $name
157+ * @param string $doctrineServiceId
158+ * @param string $name
156159 */
157160 protected function createPsr7CompliantService (ContainerBuilder $ container , $ doctrineServiceId , $ name )
158161 {
@@ -162,7 +165,7 @@ protected function createPsr7CompliantService(ContainerBuilder $container, $doct
162165 // Register the CacheItemPoolInterface definition
163166 $ def = new Definition (CachePool::class);
164167 $ def ->addArgument (new Reference ($ doctrineServiceId ));
165- $ def ->setTags (['cache.provider ' => []]);
168+ $ def ->setTags (['cache.provider ' => []]);
166169
167170 $ container ->setDefinition ($ serviceId , $ def );
168171 $ container ->setAlias ('cache.provider. ' .$ name , $ serviceId );
0 commit comments