Neos\FluidAdaptor\Core\Widget\AbstractWidgetViewHelper::setChildNodes PHP Method

setChildNodes() public method

Stores the syntax tree child nodes in the Widget Context, so they can be rendered with lateron.
public setChildNodes ( array $childNodes ) : void
$childNodes array The SyntaxTree Child nodes of this ViewHelper.
return void
    public function setChildNodes(array $childNodes)
    {
        $rootNode = new RootNode();
        foreach ($childNodes as $childNode) {
            $rootNode->addChildNode($childNode);
        }
        $this->widgetContext->setViewHelperChildNodes($rootNode, $this->renderingContext);
    }

Usage Example

 /**
  * @test
  */
 public function setChildNodesAddsChildNodesToWidgetContext()
 {
     $this->widgetContext = new \Neos\FluidAdaptor\Core\Widget\WidgetContext();
     $this->viewHelper->injectWidgetContext($this->widgetContext);
     $node1 = $this->createMock(AbstractNode::class);
     $node2 = $this->getMockBuilder(TextNode::class)->disableOriginalConstructor()->getMock();
     $node3 = $this->createMock(AbstractNode::class);
     $rootNode = new RootNode();
     $rootNode->addChildNode($node1);
     $rootNode->addChildNode($node2);
     $rootNode->addChildNode($node3);
     $renderingContext = $this->createMock(RenderingContextInterface::class);
     $this->viewHelper->_set('renderingContext', $renderingContext);
     $this->viewHelper->setChildNodes(array($node1, $node2, $node3));
     $this->assertEquals($rootNode, $this->widgetContext->getViewHelperChildNodes());
 }