public postProcess ( array $evaluateContext, object $tsObject, mixed $output ) : mixed | ||
$evaluateContext | array | The current evaluation context |
$tsObject | object | The current TypoScript object (for "this" in evaluations) |
$output | mixed | The generated output after caching information was removed |
리턴 | 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'] && $evaluateContext['cacheForPathDisabled']) {
$contextArray = $this->runtime->getCurrentContext();
if (isset($evaluateContext['configuration']['context'])) {
$contextVariables = [];
foreach ($evaluateContext['configuration']['context'] as $contextVariableName) {
$contextVariables[$contextVariableName] = $contextArray[$contextVariableName];
}
} else {
$contextVariables = $contextArray;
}
$cacheTags = $this->buildCacheTags($evaluateContext['configuration'], $evaluateContext['typoScriptPath'], $tsObject);
$cacheMetadata = array_pop($this->cacheMetadata);
$output = $this->contentCache->createDynamicCachedSegment($output, $evaluateContext['typoScriptPath'], $contextVariables, $evaluateContext['cacheIdentifierValues'], $cacheTags, $cacheMetadata['lifetime'], $evaluateContext['cacheDiscriminator']);
} elseif ($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 = [];
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;
}
/** * Does the evaluation of a TypoScript instance, first checking the cache and if conditions and afterwards applying processors. * * @param AbstractTypoScriptObject $typoScriptObject * @param string $typoScriptPath * @param array $typoScriptConfiguration * @param array $cacheContext * @return mixed */ protected function evaluateObjectOrRetrieveFromCache($typoScriptObject, $typoScriptPath, $typoScriptConfiguration, $cacheContext) { $output = null; $evaluationStatus = self::EVALUATION_SKIPPED; list($cacheHit, $cachedResult) = $this->runtimeContentCache->preEvaluate($cacheContext, $typoScriptObject); if ($cacheHit) { return $cachedResult; } $evaluateObject = true; if ($this->evaluateIfCondition($typoScriptConfiguration, $typoScriptPath, $typoScriptObject) === false) { $evaluateObject = false; } if ($evaluateObject) { $output = $typoScriptObject->evaluate(); $evaluationStatus = self::EVALUATION_EXECUTED; } $this->lastEvaluationStatus = $evaluationStatus; if ($evaluateObject) { $output = $this->evaluateProcessors($output, $typoScriptConfiguration, $typoScriptPath, $typoScriptObject); } $output = $this->runtimeContentCache->postProcess($cacheContext, $typoScriptObject, $output); return $output; }