Neos\ContentRepository\Eel\FlowQueryOperations\SiblingsOperation::evaluate PHP Method

evaluate() public method

public evaluate ( FlowQuery $flowQuery, array $arguments ) : void
$flowQuery Neos\Eel\FlowQuery\FlowQuery the FlowQuery object
$arguments array the arguments for this operation
return void
    public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = array();
        $outputNodePaths = array();
        /** @var NodeInterface $contextNode */
        foreach ($flowQuery->getContext() as $contextNode) {
            $outputNodePaths[$contextNode->getPath()] = true;
        }
        foreach ($flowQuery->getContext() as $contextNode) {
            $parentNode = $contextNode->getParent();
            if ($parentNode instanceof NodeInterface) {
                foreach ($parentNode->getChildNodes() as $childNode) {
                    if (!isset($outputNodePaths[$childNode->getPath()])) {
                        $output[] = $childNode;
                        $outputNodePaths[$childNode->getPath()] = true;
                    }
                }
            }
        }
        $flowQuery->setContext($output);
        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }

Usage Example

 /**
  * @test
  */
 public function siblingsWillReturnEmptyArrayForSiteNode()
 {
     $context = array($this->siteNode);
     $q = new FlowQuery($context);
     $operation = new SiblingsOperation();
     $operation->evaluate($q, array());
     $output = $q->getContext();
     $this->assertEquals(array(), $output);
 }
SiblingsOperation