11<?php
22
3+ /**
4+ *
5+ * This file is part of phpFastCache.
6+ *
7+ * @license MIT License (MIT)
8+ *
9+ * For full copyright and license information, please see the docs/CREDITS.txt file.
10+ *
11+ * @author Georges.L (Geolim4) <contact@geolim4.com>
12+ * @author PastisD https://github.com/PastisD
13+ * @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
14+ *
15+ */
16+
317namespace phpFastCache \Bundle \DataCollector ;
418
519use phpFastCache \Api as phpFastCacheApi ;
20+ use phpFastCache \Bundle \phpFastCacheBundle ;
621use phpFastCache \Bundle \Service \Cache ;
7- use phpFastCache \Cache \ExtendedCacheItemPoolInterface ;
822use phpFastCache \CacheManager ;
923use Symfony \Component \HttpFoundation \Request ;
1024use Symfony \Component \HttpFoundation \Response ;
@@ -17,6 +31,11 @@ class CacheCollector extends DataCollector
1731 */
1832 private $ cache ;
1933
34+ /**
35+ * @var array
36+ */
37+ private $ twig_cache_blocks = [];
38+
2039 /**
2140 * CacheCollector constructor.
2241 *
@@ -53,7 +72,9 @@ public function collect(Request $request, Response $response, \Exception $except
5372 }
5473
5574 $ this ->data = [
75+ 'twigCacheBlocks ' => $ this ->twig_cache_blocks ,
5676 'apiVersion ' => phpFastCacheApi::getVersion (),
77+ 'bundleVersion ' => phpFastCacheBundle::VERSION ,
5778 'apiChangelog ' => phpFastCacheApi::getChangelog (),
5879 'driverUsed ' => $ driverUsed ,
5980 'instances ' => $ instances ,
@@ -64,7 +85,11 @@ public function collect(Request $request, Response $response, \Exception $except
6485 'write ' => (int ) CacheManager::$ WriteHits ,
6586 ],
6687 'coreConfig ' => [
67- 'namespacePath ' => CacheManager::getNamespacePath ()
88+ 'namespacePath ' => CacheManager::getNamespacePath (),
89+ ],
90+ 'projectConfig ' => [
91+ 'twig_driver ' => $ this ->cache ->getConfig ()['twig_driver ' ],
92+ 'twig_block_debug ' => $ this ->cache ->getConfig ()['twig_block_debug ' ],
6893 ],
6994 ];
7095 }
@@ -117,6 +142,14 @@ public function getCoreConfig()
117142 return $ this ->data [ 'coreConfig ' ];
118143 }
119144
145+ /**
146+ * @return mixed
147+ */
148+ public function getProjectConfig ()
149+ {
150+ return $ this ->data [ 'projectConfig ' ];
151+ }
152+
120153 /**
121154 * @return mixed
122155 */
@@ -125,6 +158,14 @@ public function getApiVersion()
125158 return $ this ->data [ 'apiVersion ' ];
126159 }
127160
161+ /**
162+ * @return mixed
163+ */
164+ public function getBundleVersion ()
165+ {
166+ return $ this ->data [ 'bundleVersion ' ];
167+ }
168+
128169 /**
129170 * @return mixed
130171 */
@@ -133,6 +174,31 @@ public function getApiChangelog()
133174 return $ this ->data [ 'apiChangelog ' ];
134175 }
135176
177+ /**
178+ * @param string $blockName
179+ * @param array $cacheBlock
180+ * @return $this
181+ */
182+ public function setTwigCacheBlock ($ blockName , array $ cacheBlock )
183+ {
184+ if (isset ($ this ->twig_cache_blocks [$ blockName ])){
185+ $ this ->twig_cache_blocks [$ blockName ] = array_merge ($ this ->twig_cache_blocks [$ blockName ], $ cacheBlock );
186+ }else {
187+ $ this ->twig_cache_blocks [$ blockName ] = $ cacheBlock ;
188+ }
189+
190+
191+ return $ this ;
192+ }
193+
194+ /**
195+ * @return array
196+ */
197+ public function getTwigCacheBlocks ()
198+ {
199+ return $ this ->data [ 'twigCacheBlocks ' ];
200+ }
201+
136202 /**
137203 * @return string
138204 */
0 commit comments