/**
  * Return the TypoScript value relative to this TypoScript object (with processors etc applied).
  *
  * Note that subsequent calls of tsValue() with the same TypoScript path will return the same values since the
  * first evaluated value will be cached in memory.
  *
  * @param string $path
  * @return mixed
  */
 protected function tsValue($path)
 {
     $fullPath = $this->path . '/' . $path;
     if (!isset($this->tsValueCache[$fullPath])) {
         $this->tsValueCache[$fullPath] = $this->tsRuntime->evaluate($fullPath, $this);
     }
     return $this->tsValueCache[$fullPath];
 }
コード例 #2
0
 /**
  * Iterates through all subelements.
  *
  * @return \ArrayIterator
  */
 public function getIterator()
 {
     $evaluatedArray = array();
     foreach ($this->partialTypoScriptTree as $key => $value) {
         if (!is_array($value)) {
             $evaluatedArray[$key] = $value;
         } elseif (isset($value['__objectType'])) {
             $evaluatedArray[$key] = $this->tsRuntime->evaluate($this->path . '/' . $key);
         } elseif (isset($value['__eelExpression'])) {
             $evaluatedArray[$key] = $this->tsRuntime->evaluate($this->path . '/' . $key, $this->templateImplementation);
         } else {
             $evaluatedArray[$key] = new TypoScriptPathProxy($this->templateImplementation, $this->path . '/' . $key, $this->partialTypoScriptTree[$key]);
         }
     }
     return new \ArrayIterator($evaluatedArray);
 }
コード例 #3
0
 /**
  * Builds an array of string which must be used as tags for the cache entry identifier of a specific cached content segment.
  *
  * @param array $configuration
  * @param string $typoScriptPath
  * @param object $tsObject The actual TypoScript object
  * @return array
  */
 protected function buildCacheTags($configuration, $typoScriptPath, $tsObject)
 {
     $cacheTags = array();
     if (isset($configuration['entryTags'])) {
         foreach ($configuration['entryTags'] as $tagKey => $tagValue) {
             $tagValue = $this->runtime->evaluate($typoScriptPath . '/__meta/cache/entryTags/' . $tagKey, $tsObject);
             if (is_array($tagValue)) {
                 $cacheTags = array_merge($cacheTags, $tagValue);
             } elseif ((string) $tagValue !== '') {
                 $cacheTags[] = $tagValue;
             }
         }
     } else {
         $cacheTags = array(ContentCache::TAG_EVERYTHING);
     }
     return $cacheTags;
 }
コード例 #4
0
 /**
  * Finally evaluate the TypoScript path
  *
  * As PHP does not like throwing an exception here, we render any exception using the configured TypoScript exception
  * handler and will also catch and log any exceptions resulting from that as a last resort.
  *
  * @return string
  */
 public function __toString()
 {
     try {
         return (string) $this->tsRuntime->evaluate($this->path);
     } catch (\Exception $exception) {
         try {
             return $this->tsRuntime->handleRenderingException($this->path, $exception);
         } catch (\Exception $exceptionHandlerException) {
             try {
                 // Throwing an exception in __toString causes a fatal error, so if that happens we catch them and use the context dependent exception handler instead.
                 $contextDependentExceptionHandler = new \TYPO3\TypoScript\Core\ExceptionHandlers\ContextDependentHandler();
                 $contextDependentExceptionHandler->setRuntime($this->tsRuntime);
                 return $contextDependentExceptionHandler->handleRenderingException($this->path, $exception);
             } catch (\Exception $contextDepndentExceptionHandlerException) {
                 $this->systemLogger->logException($contextDepndentExceptionHandlerException, array('path' => $this->path));
                 return sprintf('<!-- Exception while rendering exception in %s: %s (%s) -->', $this->path, $contextDepndentExceptionHandlerException->getMessage(), $contextDepndentExceptionHandlerException instanceof \TYPO3\Flow\Exception ? 'see reference code ' . $contextDepndentExceptionHandlerException->getReferenceCode() . ' in log' : $contextDepndentExceptionHandlerException->getCode());
             }
         }
     }
 }
コード例 #5
0
 /**
  * @test
  * @expectedException \TYPO3\TypoScript\Exception
  * @expectedExceptionCode 1395922119
  */
 public function evaluateWithCacheModeUncachedAndUnspecifiedContextThrowsException()
 {
     $mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock();
     $runtime = new Runtime(array('foo' => array('bar' => array('__meta' => array('cache' => array('mode' => 'uncached'))))), $mockControllerContext);
     $runtime->evaluate('foo/bar');
 }