Neos\ContentRepository\Eel\FlowQueryOperations\NextAllOperation::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();
        foreach ($flowQuery->getContext() as $contextNode) {
            $nextNodes = $this->getNextForNode($contextNode);
            if (is_array($nextNodes)) {
                foreach ($nextNodes as $nextNode) {
                    if ($nextNode !== null && !isset($outputNodePaths[$nextNode->getPath()])) {
                        $outputNodePaths[$nextNode->getPath()] = true;
                        $output[] = $nextNode;
                    }
                }
            }
        }
        $flowQuery->setContext($output);
        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }

Usage Example

 /**
  * @test
  */
 public function nextAllWillReturnSecondNodeAndThirdNodeInLevelForFirstAndSecondNodeInLevel()
 {
     $context = array($this->firstNodeInLevel, $this->secondNodeInLevel);
     $q = new FlowQuery($context);
     $operation = new NextAllOperation();
     $operation->evaluate($q, array());
     $output = $q->getContext();
     $this->assertEquals(array($this->secondNodeInLevel, $this->thirdNodeInLevel), $output);
 }