Neos\Fusion\TypoScriptObjects\ArrayImplementation::evaluate PHP Method

evaluate() public method

public evaluate ( ) : string
return string
    public function evaluate()
    {
        $sortedChildTypoScriptKeys = $this->sortNestedTypoScriptKeys();
        if (count($sortedChildTypoScriptKeys) === 0) {
            return null;
        }
        $output = '';
        foreach ($sortedChildTypoScriptKeys as $key) {
            try {
                $output .= $this->tsValue($key);
            } catch (\Exception $e) {
                $output .= $this->tsRuntime->handleRenderingException($this->path . '/' . $key, $e);
            }
        }
        return $output;
    }

Usage Example

 /**
  * @test
  * @dataProvider positionalSubElements
  *
  * @param string $message
  * @param array $subElements
  * @param array $expectedKeyOrder
  */
 public function evaluateRendersKeysSortedByPositionMetaProperty($message, $subElements, $expectedKeyOrder)
 {
     $mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock();
     $mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($path) use(&$renderedPaths) {
         $renderedPaths[] = $path;
     }));
     $path = '';
     $typoScriptObjectName = 'Neos.Fusion:Array';
     $renderer = new ArrayImplementation($mockTsRuntime, $path, $typoScriptObjectName);
     foreach ($subElements as $key => $value) {
         $renderer[$key] = $value;
     }
     $renderer->evaluate();
     $this->assertSame($expectedKeyOrder, $renderedPaths, $message);
 }