@@ -17,7 +17,6 @@ |
||
| 17 | 17 | namespace Phpfastcache\Bundle\DataCollector; |
| 18 | 18 | |
| 19 | 19 | use Phpfastcache\Api as PhpfastcacheApi; |
| 20 | -use Phpfastcache\Bundle\PhpfastcacheBundle; |
|
| 21 | 20 | use Phpfastcache\Bundle\Service\Phpfastcache; |
| 22 | 21 | use Phpfastcache\CacheManager; |
| 23 | 22 | use Symfony\Component\HttpFoundation\Request; |
@@ -65,35 +65,35 @@ |
||
| 65 | 65 | } |
| 66 | 66 | $stats[ $instanceName ] = $cache->getStats(); |
| 67 | 67 | $instances[ $instanceName ] = [ |
| 68 | - 'driverName' => $cache->getDriverName(), |
|
| 69 | - 'configClassName' => \get_class( $cache->getConfig()), |
|
| 70 | - 'driverConfig' => $cache->getConfig()->toArray() |
|
| 68 | + 'driverName' => $cache->getDriverName(), |
|
| 69 | + 'configClassName' => \get_class( $cache->getConfig()), |
|
| 70 | + 'driverConfig' => $cache->getConfig()->toArray() |
|
| 71 | 71 | ]; |
| 72 | 72 | $driverUsed[ $cache->getDriverName() ] = \get_class($cache); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->data = [ |
| 76 | - 'twigCacheBlocks' => $this->twig_cache_blocks, |
|
| 77 | - 'apiVersion' => PhpfastcacheApi::getVersion(), |
|
| 78 | - 'pfcVersion' => PhpfastcacheApi::getPhpFastCacheVersion(), |
|
| 79 | - 'bundleVersion' => phpFastCacheBundle::VERSION, |
|
| 80 | - 'apiChangelog' => PhpfastcacheApi::getChangelog(), |
|
| 81 | - 'driverUsed' => $driverUsed, |
|
| 82 | - 'instances' => $instances, |
|
| 83 | - 'stats' => $stats, |
|
| 84 | - 'size' => $size, |
|
| 85 | - 'hits' => [ |
|
| 76 | + 'twigCacheBlocks' => $this->twig_cache_blocks, |
|
| 77 | + 'apiVersion' => PhpfastcacheApi::getVersion(), |
|
| 78 | + 'pfcVersion' => PhpfastcacheApi::getPhpFastCacheVersion(), |
|
| 79 | + 'bundleVersion' => phpFastCacheBundle::VERSION, |
|
| 80 | + 'apiChangelog' => PhpfastcacheApi::getChangelog(), |
|
| 81 | + 'driverUsed' => $driverUsed, |
|
| 82 | + 'instances' => $instances, |
|
| 83 | + 'stats' => $stats, |
|
| 84 | + 'size' => $size, |
|
| 85 | + 'hits' => [ |
|
| 86 | 86 | 'read' => (int) CacheManager::$ReadHits, |
| 87 | 87 | 'write' => (int) CacheManager::$WriteHits, |
| 88 | - ], |
|
| 89 | - 'coreConfig' => [ |
|
| 88 | + ], |
|
| 89 | + 'coreConfig' => [ |
|
| 90 | 90 | 'driverList' => CacheManager::getDriverList(true), |
| 91 | 91 | 'namespacePath (deprecated)' => CacheManager::getNamespacePath(), |
| 92 | - ], |
|
| 93 | - 'projectConfig' => [ |
|
| 92 | + ], |
|
| 93 | + 'projectConfig' => [ |
|
| 94 | 94 | 'twig_driver' => $this->cache->getConfig()['twig_driver'], |
| 95 | 95 | 'twig_block_debug' => $this->cache->getConfig()['twig_block_debug'], |
| 96 | - ], |
|
| 96 | + ], |
|
| 97 | 97 | ]; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | if ($cache->getStats()->getSize()) { |
| 64 | 64 | $size += $cache->getStats()->getSize(); |
| 65 | 65 | } |
| 66 | - $stats[ $instanceName ] = $cache->getStats(); |
|
| 67 | - $instances[ $instanceName ] = [ |
|
| 66 | + $stats[$instanceName] = $cache->getStats(); |
|
| 67 | + $instances[$instanceName] = [ |
|
| 68 | 68 | 'driverName' => $cache->getDriverName(), |
| 69 | - 'configClassName' => \get_class( $cache->getConfig()), |
|
| 69 | + 'configClassName' => \get_class($cache->getConfig()), |
|
| 70 | 70 | 'driverConfig' => $cache->getConfig()->toArray() |
| 71 | 71 | ]; |
| 72 | - $driverUsed[ $cache->getDriverName() ] = \get_class($cache); |
|
| 72 | + $driverUsed[$cache->getDriverName()] = \get_class($cache); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $this->data = [ |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function getStats() |
| 104 | 104 | { |
| 105 | - return $this->data[ 'stats' ]; |
|
| 105 | + return $this->data['stats']; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function getInstances() |
| 112 | 112 | { |
| 113 | - return $this->data[ 'instances' ]; |
|
| 113 | + return $this->data['instances']; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getDriverUsed() |
| 120 | 120 | { |
| 121 | - return $this->data[ 'driverUsed' ]; |
|
| 121 | + return $this->data['driverUsed']; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getHits() |
| 128 | 128 | { |
| 129 | - return $this->data[ 'hits' ]; |
|
| 129 | + return $this->data['hits']; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function getSize() |
| 136 | 136 | { |
| 137 | - return $this->data[ 'size' ]; |
|
| 137 | + return $this->data['size']; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function getCoreConfig() |
| 144 | 144 | { |
| 145 | - return $this->data[ 'coreConfig' ]; |
|
| 145 | + return $this->data['coreConfig']; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function getProjectConfig() |
| 152 | 152 | { |
| 153 | - return $this->data[ 'projectConfig' ]; |
|
| 153 | + return $this->data['projectConfig']; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | public function getApiVersion() |
| 160 | 160 | { |
| 161 | - return $this->data[ 'apiVersion' ]; |
|
| 161 | + return $this->data['apiVersion']; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function getPfcVersion() |
| 168 | 168 | { |
| 169 | - return $this->data[ 'pfcVersion' ]; |
|
| 169 | + return $this->data['pfcVersion']; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function getBundleVersion() |
| 176 | 176 | { |
| 177 | - return $this->data[ 'bundleVersion' ]; |
|
| 177 | + return $this->data['bundleVersion']; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function getApiChangelog() |
| 184 | 184 | { |
| 185 | - return $this->data[ 'apiChangelog' ]; |
|
| 185 | + return $this->data['apiChangelog']; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function setTwigCacheBlock($blockName, array $cacheBlock) |
| 194 | 194 | { |
| 195 | - if(isset($this->twig_cache_blocks[$blockName])){ |
|
| 195 | + if (isset($this->twig_cache_blocks[$blockName])) { |
|
| 196 | 196 | $this->twig_cache_blocks[$blockName] = array_merge($this->twig_cache_blocks[$blockName], $cacheBlock); |
| 197 | - }else{ |
|
| 197 | + } else { |
|
| 198 | 198 | $this->twig_cache_blocks[$blockName] = $cacheBlock; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function getTwigCacheBlocks() |
| 209 | 209 | { |
| 210 | - return $this->data[ 'twigCacheBlocks' ]; |
|
| 210 | + return $this->data['twigCacheBlocks']; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -183,7 +183,7 @@ |
||
| 183 | 183 | { |
| 184 | 184 | if(isset($this->twig_cache_blocks[$blockName])){ |
| 185 | 185 | $this->twig_cache_blocks[$blockName] = array_merge($this->twig_cache_blocks[$blockName], $cacheBlock); |
| 186 | - }else{ |
|
| 186 | + } else{ |
|
| 187 | 187 | $this->twig_cache_blocks[$blockName] = $cacheBlock; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -37,14 +37,14 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function load(array $configs, ContainerBuilder $container) |
| 39 | 39 | { |
| 40 | - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 40 | + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
| 41 | 41 | $loader->load('services.yml'); |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Includes services_dev.yml only |
| 45 | 45 | * if we are in debug mode |
| 46 | 46 | */ |
| 47 | - if(\in_array($container->getParameter('kernel.environment'), ['dev', 'test'], true)){ |
|
| 47 | + if (\in_array($container->getParameter('kernel.environment'), ['dev', 'test'], true)) { |
|
| 48 | 48 | $loader->load('services_dev.yml'); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -8,18 +8,18 @@ |
||
| 8 | 8 | public function registerBundles() |
| 9 | 9 | { |
| 10 | 10 | $bundles = [ |
| 11 | - new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
|
| 12 | - new Symfony\Bundle\SecurityBundle\SecurityBundle(), |
|
| 13 | - new Symfony\Bundle\TwigBundle\TwigBundle(), |
|
| 14 | - new Symfony\Bundle\MonologBundle\MonologBundle(), |
|
| 15 | - new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), |
|
| 16 | - new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), |
|
| 17 | - new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), |
|
| 18 | - new AppBundle\AppBundle(), |
|
| 11 | + new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
|
| 12 | + new Symfony\Bundle\SecurityBundle\SecurityBundle(), |
|
| 13 | + new Symfony\Bundle\TwigBundle\TwigBundle(), |
|
| 14 | + new Symfony\Bundle\MonologBundle\MonologBundle(), |
|
| 15 | + new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), |
|
| 16 | + new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), |
|
| 17 | + new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), |
|
| 18 | + new AppBundle\AppBundle(), |
|
| 19 | 19 | /** |
| 20 | 20 | * PhpFastCache Bundle |
| 21 | 21 | */ |
| 22 | - new Phpfastcache\Bundle\phpFastCacheBundle(), |
|
| 22 | + new Phpfastcache\Bundle\phpFastCacheBundle(), |
|
| 23 | 23 | ]; |
| 24 | 24 | |
| 25 | 25 | if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { |
@@ -39,16 +39,16 @@ |
||
| 39 | 39 | |
| 40 | 40 | public function getCacheDir() |
| 41 | 41 | { |
| 42 | - return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); |
|
| 42 | + return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment(); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function getLogDir() |
| 46 | 46 | { |
| 47 | - return dirname(__DIR__).'/var/logs'; |
|
| 47 | + return dirname(__DIR__) . '/var/logs'; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function registerContainerConfiguration(LoaderInterface $loader) |
| 51 | 51 | { |
| 52 | - $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); |
|
| 52 | + $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml'); |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -123,8 +123,8 @@ |
||
| 123 | 123 | |
| 124 | 124 | // replace this example code with whatever you need |
| 125 | 125 | return $this->render('default/index.html.twig', [ |
| 126 | - 'pfc_test' => $pfc_test, |
|
| 127 | - 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
|
| 126 | + 'pfc_test' => $pfc_test, |
|
| 127 | + 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
|
| 128 | 128 | ]); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | \ No newline at end of file |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Xcache and APC cannot coexists |
| 30 | 30 | */ |
| 31 | - try{ |
|
| 31 | + try { |
|
| 32 | 32 | $cache9 = $this->get('phpfastcache')->get('apccache'); |
| 33 | 33 | $cache10 = $this->get('phpfastcache')->get('apcucache'); |
| 34 | - }catch(PhpfastcacheDriverCheckException $e){ |
|
| 34 | + } catch (PhpfastcacheDriverCheckException $e) { |
|
| 35 | 35 | $cache11 = $this->get('phpfastcache')->get('xcachecache'); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | $item8 = $cache7->getItem('test2'); |
| 50 | 50 | $item9 = $cache8->getItem('test2'); |
| 51 | 51 | |
| 52 | - if(isset($cache9) && isset($cache10)) |
|
| 52 | + if (isset($cache9) && isset($cache10)) |
|
| 53 | 53 | { |
| 54 | 54 | $item10 = $cache9->getItem('test2'); |
| 55 | 55 | $item11 = $cache10->getItem('test2'); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if(isset($cache11)) |
|
| 58 | + if (isset($cache11)) |
|
| 59 | 59 | { |
| 60 | 60 | $item12 = $cache11->getItem('test2'); |
| 61 | 61 | } |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | $item8->set('Loaded from cache2')->expiresAfter(10); |
| 80 | 80 | $item9->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 81 | 81 | |
| 82 | - if(isset($item10) && isset($item11)) |
|
| 82 | + if (isset($item10) && isset($item11)) |
|
| 83 | 83 | { |
| 84 | 84 | $item10->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 85 | 85 | $item11->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if(isset($item12)) |
|
| 88 | + if (isset($item12)) |
|
| 89 | 89 | { |
| 90 | 90 | $item12->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 91 | 91 | } |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | $cache7->save($item8); |
| 105 | 105 | $cache8->save($item9); |
| 106 | 106 | |
| 107 | - if(isset($cache9) && isset($cache10)) |
|
| 107 | + if (isset($cache9) && isset($cache10)) |
|
| 108 | 108 | { |
| 109 | 109 | $cache9->save($item10); |
| 110 | 110 | $cache10->save($item11); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if(isset($cache11)) |
|
| 113 | + if (isset($cache11)) |
|
| 114 | 114 | { |
| 115 | 115 | $cache11->save($item12); |
| 116 | 116 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | // replace this example code with whatever you need |
| 125 | 125 | return $this->render('default/index.html.twig', [ |
| 126 | 126 | 'pfc_test' => $pfc_test, |
| 127 | - 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
|
| 127 | + 'base_dir' => realpath($this->getParameter('kernel.root_dir') . '/..'), |
|
| 128 | 128 | ]); |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | \ No newline at end of file |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | try{ |
| 32 | 32 | $cache9 = $this->get('phpfastcache')->get('apccache'); |
| 33 | 33 | $cache10 = $this->get('phpfastcache')->get('apcucache'); |
| 34 | - }catch(PhpfastcacheDriverCheckException $e){ |
|
| 34 | + } catch(PhpfastcacheDriverCheckException $e){ |
|
| 35 | 35 | $cache11 = $this->get('phpfastcache')->get('xcachecache'); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -97,11 +97,11 @@ |
||
| 97 | 97 | $configClass = $driverClass::getConfigClass(); |
| 98 | 98 | if(\class_exists($configClass)){ |
| 99 | 99 | $this->createInstance( |
| 100 | - $name, |
|
| 101 | - CacheManager::getInstance( |
|
| 100 | + $name, |
|
| 101 | + CacheManager::getInstance( |
|
| 102 | 102 | $this->config[ 'drivers' ][ $name ][ 'type' ], |
| 103 | 103 | new $configClass($this->config[ 'drivers' ][ $name ][ 'parameters' ]) |
| 104 | - ) |
|
| 104 | + ) |
|
| 105 | 105 | ); |
| 106 | 106 | }else{ |
| 107 | 107 | throw new PhpfastcacheInvalidConfigurationException('Invalid configuration class name: ' . $configClass); |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function createInstance($name, ExtendedCacheItemPoolInterface $instance) |
| 70 | 70 | { |
| 71 | - if (\array_key_exists($name, $this->cacheInstances) && $this->cacheInstances[ $name ] instanceof ExtendedCacheItemPoolInterface) { |
|
| 71 | + if (\array_key_exists($name, $this->cacheInstances) && $this->cacheInstances[$name] instanceof ExtendedCacheItemPoolInterface) { |
|
| 72 | 72 | throw new PhpfastcacheDriverException("Cache instance '{$name}' already exists"); |
| 73 | 73 | } |
| 74 | - $this->cacheInstances[ $name ] = $instance; |
|
| 74 | + $this->cacheInstances[$name] = $instance; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -91,24 +91,24 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if (!\array_key_exists($name, $this->cacheInstances)) { |
| 94 | - if (\array_key_exists($name, $this->config[ 'drivers' ])) { |
|
| 95 | - $driverClass = CacheManager::getDriverClass($this->config[ 'drivers' ][ $name ][ 'type' ]); |
|
| 96 | - if (\is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){ |
|
| 94 | + if (\array_key_exists($name, $this->config['drivers'])) { |
|
| 95 | + $driverClass = CacheManager::getDriverClass($this->config['drivers'][$name]['type']); |
|
| 96 | + if (\is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) { |
|
| 97 | 97 | $configClass = $driverClass::getConfigClass(); |
| 98 | - if(\class_exists($configClass)){ |
|
| 98 | + if (\class_exists($configClass)) { |
|
| 99 | 99 | $this->createInstance( |
| 100 | 100 | $name, |
| 101 | 101 | CacheManager::getInstance( |
| 102 | - $this->config[ 'drivers' ][ $name ][ 'type' ], |
|
| 103 | - new $configClass($this->config[ 'drivers' ][ $name ][ 'parameters' ]) |
|
| 102 | + $this->config['drivers'][$name]['type'], |
|
| 103 | + new $configClass($this->config['drivers'][$name]['parameters']) |
|
| 104 | 104 | ) |
| 105 | 105 | ); |
| 106 | - }else{ |
|
| 106 | + } else { |
|
| 107 | 107 | throw new PhpfastcacheInvalidConfigurationException('Invalid configuration class name: ' . $configClass); |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if (!isset($this->cacheInstances[ $name ]) || !($this->cacheInstances[ $name ] instanceof ExtendedCacheItemPoolInterface)) { |
|
| 111 | + if (!isset($this->cacheInstances[$name]) || !($this->cacheInstances[$name] instanceof ExtendedCacheItemPoolInterface)) { |
|
| 112 | 112 | throw new PhpfastcacheDriverException("Cache instance '{$name}' does not implements ExtendedCacheItemPoolInterface"); |
| 113 | 113 | } |
| 114 | 114 | } else { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | if ($this->stopwatch) { |
| 120 | 120 | $this->stopwatch->stop(__METHOD__ . "('{$name}')"); |
| 121 | 121 | } |
| 122 | - return $this->cacheInstances[ $name ]; |
|
| 122 | + return $this->cacheInstances[$name]; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function getTwigCacheInstance(): ExtendedCacheItemPoolInterface |
| 129 | 129 | { |
| 130 | - return $this->get($this->config[ 'twig_driver' ]); |
|
| 130 | + return $this->get($this->config['twig_driver']); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -103,7 +103,7 @@ |
||
| 103 | 103 | new $configClass($this->config[ 'drivers' ][ $name ][ 'parameters' ]) |
| 104 | 104 | ) |
| 105 | 105 | ); |
| 106 | - }else{ |
|
| 106 | + } else{ |
|
| 107 | 107 | throw new PhpfastcacheInvalidConfigurationException('Invalid configuration class name: ' . $configClass); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $callback = function($name) use ($phpFastCache, $output, &$failedInstances) |
| 52 | 52 | { |
| 53 | - try{ |
|
| 53 | + try { |
|
| 54 | 54 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
| 55 | 55 | $output->writeln("<fg=yellow>Clearing instance {$name} cache...</>"); |
| 56 | 56 | } |
@@ -58,35 +58,35 @@ discard block |
||
| 58 | 58 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
| 59 | 59 | $output->writeln("<fg=green>Cache instance {$name} cleared</>"); |
| 60 | 60 | } |
| 61 | - }catch (PhpfastcacheDriverCheckException $e){ |
|
| 61 | + } catch (PhpfastcacheDriverCheckException $e) { |
|
| 62 | 62 | $failedInstances[] = $name; |
| 63 | 63 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
| 64 | - $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() ."</>"); |
|
| 65 | - }else{ |
|
| 64 | + $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() . "</>"); |
|
| 65 | + } else { |
|
| 66 | 66 | $output->writeln("<fg=red>Cache instance {$name} not cleared (increase verbosity to get more information).</>"); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | }; |
| 70 | 70 | $caches = $this->getContainer()->getParameter('phpfastcache'); |
| 71 | 71 | |
| 72 | - if($driver) { |
|
| 73 | - if(\array_key_exists($driver, $caches['drivers'])){ |
|
| 72 | + if ($driver) { |
|
| 73 | + if (\array_key_exists($driver, $caches['drivers'])) { |
|
| 74 | 74 | $callback($driver); |
| 75 | - if(!\count($failedInstances)){ |
|
| 75 | + if (!\count($failedInstances)) { |
|
| 76 | 76 | $io->success("Cache instance {$driver} cleared"); |
| 77 | - }else{ |
|
| 77 | + } else { |
|
| 78 | 78 | $io->error("Cache instance {$driver} not cleared"); |
| 79 | 79 | } |
| 80 | - }else{ |
|
| 80 | + } else { |
|
| 81 | 81 | $io->error("Cache instance {$driver} does not exists"); |
| 82 | 82 | } |
| 83 | 83 | } else { |
| 84 | - foreach($caches['drivers'] as $name => $parameters) { |
|
| 84 | + foreach ($caches['drivers'] as $name => $parameters) { |
|
| 85 | 85 | $callback($name); |
| 86 | 86 | } |
| 87 | - if(!\count($failedInstances)){ |
|
| 87 | + if (!\count($failedInstances)) { |
|
| 88 | 88 | $io->success('All caches instances got cleared'); |
| 89 | - }else{ |
|
| 89 | + } else { |
|
| 90 | 90 | $io->success('Almost all caches instances got cleared, except these: ' . \implode(', ', $failedInstances)); |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
| 59 | 59 | $output->writeln("<fg=green>Cache instance {$name} cleared</>"); |
| 60 | 60 | } |
| 61 | - }catch (PhpfastcacheDriverCheckException $e){ |
|
| 61 | + } catch (PhpfastcacheDriverCheckException $e){ |
|
| 62 | 62 | $failedInstances[] = $name; |
| 63 | 63 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
| 64 | 64 | $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() ."</>"); |
| 65 | - }else{ |
|
| 65 | + } else{ |
|
| 66 | 66 | $output->writeln("<fg=red>Cache instance {$name} not cleared (increase verbosity to get more information).</>"); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | $callback($driver); |
| 75 | 75 | if(!\count($failedInstances)){ |
| 76 | 76 | $io->success("Cache instance {$driver} cleared"); |
| 77 | - }else{ |
|
| 77 | + } else{ |
|
| 78 | 78 | $io->error("Cache instance {$driver} not cleared"); |
| 79 | 79 | } |
| 80 | - }else{ |
|
| 80 | + } else{ |
|
| 81 | 81 | $io->error("Cache instance {$driver} does not exists"); |
| 82 | 82 | } |
| 83 | 83 | } else { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | if(!\count($failedInstances)){ |
| 88 | 88 | $io->success('All caches instances got cleared'); |
| 89 | - }else{ |
|
| 89 | + } else{ |
|
| 90 | 90 | $io->success('Almost all caches instances got cleared, except these: ' . \implode(', ', $failedInstances)); |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $generationTime = microtime(true) - $generationTimeMc; |
| 76 | 76 | $unprefixedKey = substr($key['key'], strlen($this->twigCachePrefix)); |
| 77 | 77 | |
| 78 | - if($this->cacheCollector instanceof CacheCollector){ |
|
| 78 | + if ($this->cacheCollector instanceof CacheCollector) { |
|
| 79 | 79 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
| 80 | 80 | 'cacheHit' => $cacheData !== null, |
| 81 | 81 | 'cacheTtl' => $key['lifetime'], |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ]); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if(!empty($cacheData) && $this->config['twig_block_debug']){ |
|
| 87 | + if (!empty($cacheData) && $this->config['twig_block_debug']) { |
|
| 88 | 88 | return "<!-- BEGIN CACHE BLOCK OUTPUT '{$unprefixedKey}' -->\n{$cacheData}\n<!-- // END CACHE BLOCK OUTPUT '{$unprefixedKey}' -->"; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $unprefixedKey = substr($key['key'], strlen($this->twigCachePrefix)); |
| 115 | 115 | |
| 116 | - if($this->cacheCollector instanceof CacheCollector){ |
|
| 116 | + if ($this->cacheCollector instanceof CacheCollector) { |
|
| 117 | 117 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
| 118 | 118 | 'cacheHit' => false, |
| 119 | 119 | 'cacheTtl' => $key['lifetime'], |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $compiler |
| 55 | 55 | ->addDebugInfo($this) |
| 56 | - ->write("\$phpfastcacheCacheStrategy".$i." = \$this->env->getExtension('{$extension}')->getCacheStrategy();\n") |
|
| 57 | - ->write("\$phpfastcacheKey".$i." = \$phpfastcacheCacheStrategy".$i."->generateKey(") |
|
| 56 | + ->write("\$phpfastcacheCacheStrategy" . $i . " = \$this->env->getExtension('{$extension}')->getCacheStrategy();\n") |
|
| 57 | + ->write("\$phpfastcacheKey" . $i . " = \$phpfastcacheCacheStrategy" . $i . "->generateKey(") |
|
| 58 | 58 | ->subcompile($this->getNode('annotation')) |
| 59 | 59 | ->raw(", ") |
| 60 | 60 | ->subcompile($this->getNode('key_info')) |
| 61 | 61 | ->write(");\n") |
| 62 | - ->write("\$phpfastcacheCacheBody".$i." = \$phpfastcacheCacheStrategy".$i."->fetchBlock(\$phpfastcacheKey".$i.");\n") |
|
| 63 | - ->write("if (\$phpfastcacheCacheBody".$i." === false) {\n") |
|
| 62 | + ->write("\$phpfastcacheCacheBody" . $i . " = \$phpfastcacheCacheStrategy" . $i . "->fetchBlock(\$phpfastcacheKey" . $i . ");\n") |
|
| 63 | + ->write("if (\$phpfastcacheCacheBody" . $i . " === false) {\n") |
|
| 64 | 64 | ->indent() |
| 65 | 65 | ->write("\\ob_start();\n") |
| 66 | 66 | ->write("\$compileMc = \\microtime(true);\n") |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | ->outdent() |
| 70 | 70 | ->write("\n") |
| 71 | 71 | // ->write("sleep(2);\n") // For debug purpose |
| 72 | - ->write("\$phpfastcacheCacheBody".$i." = \\ob_get_clean();\n") |
|
| 73 | - ->write("\$phpfastcacheCacheStrategy".$i."->saveBlock(\$phpfastcacheKey".$i.", \$phpfastcacheCacheBody".$i.", \\microtime(true) - \$compileMc);\n") |
|
| 72 | + ->write("\$phpfastcacheCacheBody" . $i . " = \\ob_get_clean();\n") |
|
| 73 | + ->write("\$phpfastcacheCacheStrategy" . $i . "->saveBlock(\$phpfastcacheKey" . $i . ", \$phpfastcacheCacheBody" . $i . ", \\microtime(true) - \$compileMc);\n") |
|
| 74 | 74 | ->outdent() |
| 75 | 75 | ->write("}\n") |
| 76 | - ->write("echo \$phpfastcacheCacheBody".$i.";\n") |
|
| 76 | + ->write("echo \$phpfastcacheCacheBody" . $i . ";\n") |
|
| 77 | 77 | ; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | public function getTokenParsers() |
| 60 | 60 | { |
| 61 | 61 | return [ |
| 62 | - new TokenParser\Cache(), |
|
| 62 | + new TokenParser\Cache(), |
|
| 63 | 63 | ]; |
| 64 | 64 | } |
| 65 | 65 | } |