Neos\Fusion\TypoScriptObjects\ArrayImplementation::evaluate PHP Méthode

evaluate() public méthode

public evaluate ( ) : string
Résultat 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);
 }