Neos\Fusion\Core\Cache\RuntimeContentCache::enter PHP Метод

enter() публичный Метод

Needs to be called right before evaluation of a path starts to check the cache mode and set internal state like the cache entry point.
public enter ( array $configuration, string $typoScriptPath ) : array
$configuration array
$typoScriptPath string
Результат array An evaluate context array that needs to be passed to subsequent calls to pass the current state
    public function enter(array $configuration, $typoScriptPath)
    {
        $cacheForPathEnabled = isset($configuration['mode']) && ($configuration['mode'] === 'cached' || $configuration['mode'] === 'dynamic');
        $cacheForPathDisabled = isset($configuration['mode']) && ($configuration['mode'] === 'uncached' || $configuration['mode'] === 'dynamic');
        if ($cacheForPathDisabled && (!isset($configuration['context']) || $configuration['context'] === [])) {
            throw new Exception(sprintf('Missing @cache.context configuration for path "%s". An uncached segment must have one or more context variable names configured.', $typoScriptPath), 1395922119);
        }
        $currentPathIsEntryPoint = false;
        if ($this->enableContentCache && $cacheForPathEnabled) {
            if ($this->inCacheEntryPoint === null) {
                $this->inCacheEntryPoint = true;
                $currentPathIsEntryPoint = true;
            }
        }
        return ['configuration' => $configuration, 'typoScriptPath' => $typoScriptPath, 'cacheForPathEnabled' => $cacheForPathEnabled, 'cacheForPathDisabled' => $cacheForPathDisabled, 'currentPathIsEntryPoint' => $currentPathIsEntryPoint];
    }

Usage Example

Пример #1
0
 /**
  * Internal evaluation method of absolute $typoScriptPath
  *
  * @param string $typoScriptPath
  * @param string $behaviorIfPathNotFound one of BEHAVIOR_EXCEPTION or BEHAVIOR_RETURNNULL
  * @param mixed $contextObject the object which will be "this" in Eel expressions, if any
  * @return mixed
  *
  * @throws StopActionException
  * @throws SecurityException
  * @throws Exception
  * @throws RuntimeException
  */
 protected function evaluateInternal($typoScriptPath, $behaviorIfPathNotFound, $contextObject = null)
 {
     $needToPopContext = false;
     $this->lastEvaluationStatus = self::EVALUATION_EXECUTED;
     $typoScriptConfiguration = $this->getConfigurationForPath($typoScriptPath);
     $cacheContext = $this->runtimeContentCache->enter(isset($typoScriptConfiguration['__meta']['cache']) ? $typoScriptConfiguration['__meta']['cache'] : [], $typoScriptPath);
     if (!$this->canRenderWithConfiguration($typoScriptConfiguration)) {
         $this->finalizePathEvaluation($cacheContext);
         $this->throwExceptionForUnrenderablePathIfNeeded($typoScriptPath, $typoScriptConfiguration, $behaviorIfPathNotFound);
         $this->lastEvaluationStatus = self::EVALUATION_SKIPPED;
         return null;
     }
     try {
         if ($this->hasExpressionOrValue($typoScriptConfiguration)) {
             return $this->evaluteExpressionOrValueInternal($typoScriptPath, $typoScriptConfiguration, $cacheContext, $contextObject);
         }
         $typoScriptObject = $this->instantiateTypoScriptObject($typoScriptPath, $typoScriptConfiguration);
         $needToPopContext = $this->prepareContextForTypoScriptObject($typoScriptObject, $typoScriptPath, $typoScriptConfiguration, $cacheContext);
         $output = $this->evaluateObjectOrRetrieveFromCache($typoScriptObject, $typoScriptPath, $typoScriptConfiguration, $cacheContext);
     } catch (StopActionException $stopActionException) {
         $this->finalizePathEvaluation($cacheContext, $needToPopContext);
         throw $stopActionException;
     } catch (SecurityException $securityException) {
         $this->finalizePathEvaluation($cacheContext, $needToPopContext);
         throw $securityException;
     } catch (RuntimeException $runtimeException) {
         $this->finalizePathEvaluation($cacheContext, $needToPopContext);
         throw $runtimeException;
     } catch (\Exception $exception) {
         $this->finalizePathEvaluation($cacheContext, $needToPopContext);
         return $this->handleRenderingException($typoScriptPath, $exception, true);
     }
     $this->finalizePathEvaluation($cacheContext, $needToPopContext);
     return $output;
 }