/** * Flush caches according to the previously registered node changes. * * @return void */ public function shutdownObject() { if ($this->tagsToFlush !== array()) { foreach ($this->tagsToFlush as $tag => $logMessage) { $affectedEntries = $this->contentCache->flushByTag($tag); if ($affectedEntries > 0) { $this->systemLogger->log(sprintf('Content cache: Removed %s entries %s', $affectedEntries, $logMessage), LOG_DEBUG); } } } }
/** * Post process output for caching information * * The content cache stores cache segments with markers inside the generated content. This method creates cache * segments and will process the final outer result (currentPathIsEntryPoint) to remove all cache markers and * store cache entries. * * @param array $evaluateContext The current evaluation context * @param object $tsObject The current TypoScript object (for "this" in evaluations) * @param mixed $output The generated output after caching information was removed * @return mixed The post-processed output with cache segment markers or cleaned for the entry point */ public function postProcess(array $evaluateContext, $tsObject, $output) { if ($this->enableContentCache && $evaluateContext['cacheForPathEnabled']) { $cacheTags = $this->buildCacheTags($evaluateContext['configuration'], $evaluateContext['typoScriptPath'], $tsObject); $cacheMetadata = array_pop($this->cacheMetadata); $output = $this->contentCache->createCacheSegment($output, $evaluateContext['typoScriptPath'], $evaluateContext['cacheIdentifierValues'], $cacheTags, $cacheMetadata['lifetime']); } elseif ($this->enableContentCache && $evaluateContext['cacheForPathDisabled'] && $this->inCacheEntryPoint) { $contextArray = $this->runtime->getCurrentContext(); if (isset($evaluateContext['configuration']['context'])) { $contextVariables = array(); foreach ($evaluateContext['configuration']['context'] as $contextVariableName) { if (isset($contextArray[$contextVariableName])) { $contextVariables[$contextVariableName] = $contextArray[$contextVariableName]; } else { $contextVariables[$contextVariableName] = NULL; } } } else { $contextVariables = $contextArray; } $output = $this->contentCache->createUncachedSegment($output, $evaluateContext['typoScriptPath'], $contextVariables); } if ($evaluateContext['cacheForPathEnabled'] && $evaluateContext['currentPathIsEntryPoint']) { $output = $this->contentCache->processCacheSegments($output, $this->enableContentCache); $this->inCacheEntryPoint = NULL; $this->addCacheSegmentMarkersToPlaceholders = FALSE; } return $output; }
/** * Render the node * * @return string */ protected function renderContent(ControllerContext $controllerContext) { $this->contentCache->flushByTag(sprintf('Node_%s', $this->getNode()->getParent()->getIdentifier())); $parentDomAddress = $this->getParentDomAddress(); $fusionView = new FusionView(); $fusionView->setControllerContext($controllerContext); $fusionView->assign('value', $this->getNode()->getParent()); $fusionView->setTypoScriptPath($parentDomAddress->getFusionPath()); return $fusionView->render(); }
/** * @test */ public function exceptionInAlreadyCachedSegmentShouldNotLeaveSegmentMarkersInOutput() { $object = new TestModel(42, 'Object value 1'); $view = $this->buildView(); $view->setOption('enableContentCache', true); $view->setTypoScriptPath('contentCache/nestedCacheSegmentsWithConditionalException'); $view->assign('object', $object); $view->assign('throwException', false); $firstRenderResult = $view->render(); $this->assertEquals('Cached segment|counter=1|It depends|End segment', $firstRenderResult); $this->contentCache->flushByTag('Inner'); $view->assign('throwException', true); $secondRenderResult = $view->render(); $this->assertStringStartsWith('Cached segment|counter=1|Exception', $secondRenderResult); }
/** * Displays the backend interface * * @param NodeInterface $node The node that will be displayed on the first tab * @return void */ public function indexAction(NodeInterface $node = null) { $this->contentCache->flush(); $this->session->start(); $this->session->putData('__cheEnabled__', true); if ($user = $this->userService->getBackendUser()) { $workspaceName = $this->userService->getPersonalWorkspaceName(); $contentContext = $this->createContext($workspaceName); $contentContext->getWorkspace(); $this->persistenceManager->persistAll(); $siteNode = $contentContext->getCurrentSiteNode(); if ($node === null) { $node = $siteNode; } $this->view->assign('user', $user); $this->view->assign('documentNode', $node); $this->view->assign('site', $node); $this->view->assign('translations', $this->xliffService->getCachedJson(new Locale($this->userService->getInterfaceLanguage()))); return; } $this->redirectToUri($this->uriBuilder->uriFor('index', array(), 'Login', 'TYPO3.Neos')); }
/** * @Flow\Before("method(TYPO3\Neos\Controller\Backend\BackendController->indexAction())") * @param JoinPointInterface $joinPoint the join point * @return mixed */ public function disableNewUserInterface(JoinPointInterface $joinPoint) { $this->contentCache->flush(); $this->session->start(); $this->session->putData('__cheEnabled__', false); }
/** * @param LifecycleEventArgs $eventArgs * @return void */ public function postUpdate(LifecycleEventArgs $eventArgs) { if ($eventArgs->getEntity() instanceof BadgeClass) { $this->contentCache->flushByTag('BadgeClass_' . $this->persistenceManager->getIdentifierByObject($eventArgs->getEntity())); } }