evaluate() public method

Evaluate an absolute TypoScript path and return the result
public evaluate ( string $typoScriptPath, object $contextObject = null ) : mixed
$typoScriptPath string
$contextObject object the object available as "this" in Eel expressions. ONLY FOR INTERNAL USE!
return mixed the result of the evaluation, can be a string but also other data types
Esempio n. 1
0
 /**
  * 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];
 }
Esempio n. 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->fusionRuntime->evaluate($this->path . '/' . $key);
         } elseif (isset($value['__eelExpression'])) {
             $evaluatedArray[$key] = $this->fusionRuntime->evaluate($this->path . '/' . $key, $this->templateImplementation);
         } else {
             $evaluatedArray[$key] = new FusionPathProxy($this->templateImplementation, $this->path . '/' . $key, $this->partialTypoScriptTree[$key]);
         }
     }
     return new \ArrayIterator($evaluatedArray);
 }
 /**
  * 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(array $configuration, $typoScriptPath, $tsObject)
 {
     $cacheTags = [];
     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;
             }
         }
         foreach ($this->flushTags() as $tagKey => $tagValue) {
             $cacheTags[] = $tagValue;
         }
     } else {
         $cacheTags = [ContentCache::TAG_EVERYTHING];
     }
     return array_unique($cacheTags);
 }
 /**
  * @test
  * @expectedException \Neos\Fusion\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');
 }