@@ -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); |
@@ -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 | } |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function createInstance(string $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 | /** |
@@ -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 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $callback = function($name) use ($output, &$failedInstances) |
81 | 81 | { |
82 | - try{ |
|
82 | + try { |
|
83 | 83 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
84 | 84 | $output->writeln("<fg=yellow>Clearing instance {$name} cache...</>"); |
85 | 85 | } |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
88 | 88 | $output->writeln("<fg=green>Cache instance {$name} cleared</>"); |
89 | 89 | } |
90 | - }catch (PhpfastcacheDriverCheckException $e){ |
|
90 | + } catch (PhpfastcacheDriverCheckException $e) { |
|
91 | 91 | $failedInstances[] = $name; |
92 | 92 | if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { |
93 | - $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() ."</>"); |
|
94 | - }else{ |
|
93 | + $output->writeln("<fg=red>Cache instance {$name} not cleared, got exception: " . "<bg=red;options=bold>" . $e->getMessage() . "</>"); |
|
94 | + } else { |
|
95 | 95 | $output->writeln("<fg=red>Cache instance {$name} not cleared (increase verbosity to get more information).</>"); |
96 | 96 | } |
97 | 97 | } |
@@ -99,24 +99,24 @@ discard block |
||
99 | 99 | |
100 | 100 | $caches = $this->parameters; |
101 | 101 | |
102 | - if($driver) { |
|
103 | - if(\array_key_exists($driver, $caches['drivers'])){ |
|
102 | + if ($driver) { |
|
103 | + if (\array_key_exists($driver, $caches['drivers'])) { |
|
104 | 104 | $callback($driver); |
105 | - if(!\count($failedInstances)){ |
|
105 | + if (!\count($failedInstances)) { |
|
106 | 106 | $io->success("Cache instance {$driver} cleared"); |
107 | - }else{ |
|
107 | + } else { |
|
108 | 108 | $io->error("Cache instance {$driver} not cleared"); |
109 | 109 | } |
110 | - }else{ |
|
110 | + } else { |
|
111 | 111 | $io->error("Cache instance {$driver} does not exists"); |
112 | 112 | } |
113 | 113 | } else { |
114 | - foreach($caches['drivers'] as $name => $parameters) { |
|
114 | + foreach ($caches['drivers'] as $name => $parameters) { |
|
115 | 115 | $callback($name); |
116 | 116 | } |
117 | - if(!\count($failedInstances)){ |
|
117 | + if (!\count($failedInstances)) { |
|
118 | 118 | $io->success('All caches instances got cleared'); |
119 | - }else{ |
|
119 | + } else { |
|
120 | 120 | $io->success('Almost all caches instances got cleared, except these: ' . \implode(', ', $failedInstances)); |
121 | 121 | } |
122 | 122 | } |
@@ -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 | } |
@@ -36,9 +36,9 @@ |
||
36 | 36 | public function __construct(\Twig_Node_Expression $annotation, \Twig_Node_Expression $keyInfo, \Twig_Node $body, $lineno, $tag = null) |
37 | 37 | { |
38 | 38 | parent::__construct([ |
39 | - 'key_info' => $keyInfo, |
|
40 | - 'body' => $body, |
|
41 | - 'annotation' => $annotation |
|
39 | + 'key_info' => $keyInfo, |
|
40 | + 'body' => $body, |
|
41 | + 'annotation' => $annotation |
|
42 | 42 | ], [], $lineno, $tag); |
43 | 43 | } |
44 | 44 |
@@ -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 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | public function getFilters() |
29 | 29 | { |
30 | 30 | return [ |
31 | - new \Twig_SimpleFilter('sizeFormat', [$this, 'size_format']), |
|
31 | + new \Twig_SimpleFilter('sizeFormat', [$this, 'size_format']), |
|
32 | 32 | ]; |
33 | 33 | } |
34 | 34 |
@@ -42,11 +42,11 @@ |
||
42 | 42 | */ |
43 | 43 | public function size_format($bytes, $decimals = 2, $octetFormat = false, $separator = '') |
44 | 44 | { |
45 | - $bytes = (int)$bytes; |
|
45 | + $bytes = (int) $bytes; |
|
46 | 46 | $sz = 'BKMGTP'; |
47 | 47 | $factor = floor((\strlen($bytes) - 1) / 3); |
48 | 48 | |
49 | - return sprintf("%.{$decimals}f", $bytes / (1024 ** $factor)) . $separator . @$sz[ $factor ] . ($factor ? ($octetFormat ? 'O' : 'B') : ''); |
|
49 | + return sprintf("%.{$decimals}f", $bytes / (1024 ** $factor)) . $separator . @$sz[$factor] . ($factor ? ($octetFormat ? 'O' : 'B') : ''); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | |
78 | 78 | if ($this->cacheCollector instanceof CacheCollector) { |
79 | 79 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
80 | - 'cacheHit' => $cacheData !== null, |
|
81 | - 'cacheTtl' => $key[ 'lifetime' ], |
|
82 | - 'cacheSize' => mb_strlen((string)$cacheData), |
|
83 | - 'cacheGenTime' => $generationTime, |
|
80 | + 'cacheHit' => $cacheData !== null, |
|
81 | + 'cacheTtl' => $key[ 'lifetime' ], |
|
82 | + 'cacheSize' => mb_strlen((string)$cacheData), |
|
83 | + 'cacheGenTime' => $generationTime, |
|
84 | 84 | ]); |
85 | 85 | } |
86 | 86 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | return [ |
104 | - 'lifetime' => $value, |
|
105 | - 'key' => $this->twigCachePrefix . $annotation, |
|
104 | + 'lifetime' => $value, |
|
105 | + 'key' => $this->twigCachePrefix . $annotation, |
|
106 | 106 | ]; |
107 | 107 | } |
108 | 108 | |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | |
116 | 116 | if ($this->cacheCollector instanceof CacheCollector) { |
117 | 117 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
118 | - 'cacheHit' => false, |
|
119 | - 'cacheTtl' => $key[ 'lifetime' ], |
|
120 | - 'cacheSize' => \mb_strlen((string)$block), |
|
121 | - 'cacheGenTime' => $generationTime, |
|
118 | + 'cacheHit' => false, |
|
119 | + 'cacheTtl' => $key[ 'lifetime' ], |
|
120 | + 'cacheSize' => \mb_strlen((string)$block), |
|
121 | + 'cacheGenTime' => $generationTime, |
|
122 | 122 | ]); |
123 | 123 | } |
124 | 124 |
@@ -71,20 +71,20 @@ discard block |
||
71 | 71 | public function fetchBlock($key) |
72 | 72 | { |
73 | 73 | $generationTimeMc = microtime(true); |
74 | - $cacheData = $this->cache->fetch($key[ 'key' ]); |
|
74 | + $cacheData = $this->cache->fetch($key['key']); |
|
75 | 75 | $generationTime = microtime(true) - $generationTimeMc; |
76 | - $unprefixedKey = substr($key[ 'key' ], strlen($this->twigCachePrefix)); |
|
76 | + $unprefixedKey = substr($key['key'], strlen($this->twigCachePrefix)); |
|
77 | 77 | |
78 | 78 | if ($this->cacheCollector instanceof CacheCollector) { |
79 | 79 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
80 | 80 | 'cacheHit' => $cacheData !== null, |
81 | - 'cacheTtl' => $key[ 'lifetime' ], |
|
82 | - 'cacheSize' => mb_strlen((string)$cacheData), |
|
81 | + 'cacheTtl' => $key['lifetime'], |
|
82 | + 'cacheSize' => mb_strlen((string) $cacheData), |
|
83 | 83 | 'cacheGenTime' => $generationTime, |
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 | |
@@ -111,17 +111,17 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function saveBlock($key, $block, $generationTime) |
113 | 113 | { |
114 | - $unprefixedKey = \substr($key[ 'key' ], \strlen($this->twigCachePrefix)); |
|
114 | + $unprefixedKey = \substr($key['key'], \strlen($this->twigCachePrefix)); |
|
115 | 115 | |
116 | 116 | if ($this->cacheCollector instanceof CacheCollector) { |
117 | 117 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
118 | 118 | 'cacheHit' => false, |
119 | - 'cacheTtl' => $key[ 'lifetime' ], |
|
120 | - 'cacheSize' => \mb_strlen((string)$block), |
|
119 | + 'cacheTtl' => $key['lifetime'], |
|
120 | + 'cacheSize' => \mb_strlen((string) $block), |
|
121 | 121 | 'cacheGenTime' => $generationTime, |
122 | 122 | ]); |
123 | 123 | } |
124 | 124 | |
125 | - return $this->cache->save($key[ 'key' ], $block, $key[ 'lifetime' ]); |
|
125 | + return $this->cache->save($key['key'], $block, $key['lifetime']); |
|
126 | 126 | } |
127 | 127 | } |