TYPO3 CMS  TYPO3_6-2
CacheService.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $pageIdStack;
26 
30  protected $cacheManager;
31 
35  public function injectCacheManager(\TYPO3\CMS\Core\Cache\CacheManager $cacheManager) {
36  $this->cacheManager = $cacheManager;
37  }
38 
42  public function __construct() {
43  $this->pageIdStack = new \SplStack;
44  }
45 
49  public function getPageIdStack() {
50  return $this->pageIdStack;
51  }
52 
59  public function clearPageCache($pageIdsToClear = NULL) {
60  if ($pageIdsToClear === NULL) {
61  $this->cacheManager->flushCachesInGroup('pages');
62  } else {
63  if (!is_array($pageIdsToClear)) {
64  $pageIdsToClear = array((int)$pageIdsToClear);
65  }
66  foreach ($pageIdsToClear as $pageId) {
67  $this->cacheManager->flushCachesInGroupByTag('pages', 'pageId_' . $pageId);
68  }
69  }
70  }
71 
78  public function clearCachesOfRegisteredPageIds() {
79  if (!$this->pageIdStack->isEmpty()) {
80  $pageIds = array();
81  while (!$this->pageIdStack->isEmpty()) {
82  $pageIds[] = (int)$this->pageIdStack->pop();
83  }
84  $pageIds = array_values(array_unique($pageIds));
85  $this->clearPageCache($pageIds);
86  }
87  }
88 }
clearPageCache($pageIdsToClear=NULL)
injectCacheManager(\TYPO3\CMS\Core\Cache\CacheManager $cacheManager)