Neos\ContentRepository\Eel\FlowQueryOperations\PrevAllOperation::evaluate PHP Метод

evaluate() публичный Метод

public evaluate ( FlowQuery $flowQuery, array $arguments ) : void
$flowQuery Neos\Eel\FlowQuery\FlowQuery the FlowQuery object
$arguments array the arguments for this operation
Результат void
    public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = array();
        $outputNodePaths = array();
        foreach ($flowQuery->getContext() as $contextNode) {
            $prevNodes = $this->getPrevForNode($contextNode);
            if (is_array($prevNodes)) {
                foreach ($prevNodes as $prevNode) {
                    if ($prevNode !== null && !isset($outputNodePaths[$prevNode->getPath()])) {
                        $outputNodePaths[$prevNode->getPath()] = true;
                        $output[] = $prevNode;
                    }
                }
            }
        }
        $flowQuery->setContext($output);
        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }

Usage Example

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