cacheManager = $cacheManager; } /** * Initializes the pageIdStack */ public function __construct() { $this->pageIdStack = new \SplStack; } /** * @return \SplStack */ public function getPageIdStack() { return $this->pageIdStack; } /** * Clears the page cache * * @param mixed $pageIdsToClear (int) single or (array) multiple pageIds to clear the cache for */ public function clearPageCache($pageIdsToClear = null) { if ($pageIdsToClear === null) { $this->cacheManager->flushCachesInGroup('pages'); } else { if (!is_array($pageIdsToClear)) { $pageIdsToClear = [(int)$pageIdsToClear]; } $tags = array_map(function ($item) { return 'pageId_' . $item; }, $pageIdsToClear); $this->cacheManager->flushCachesInGroupByTags('pages', $tags); } } /** * Walks through the pageIdStack, collects all pageIds * as array and passes them on to clearPageCache. */ public function clearCachesOfRegisteredPageIds() { if (!$this->pageIdStack->isEmpty()) { $pageIds = []; while (!$this->pageIdStack->isEmpty()) { $pageIds[] = (int)$this->pageIdStack->pop(); } $pageIds = array_values(array_unique($pageIds)); $this->clearPageCache($pageIds); } } }