Neos\ContentRepository\Eel\FlowQueryOperations\PrevOperation::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) {
            $prevNode = $this->getPrevForNode($contextNode);
            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 prevWillReturnFirstNodeAndSecondNodeInLevelForSecondAndThirdNodeInLevel()
 {
     $context = array($this->secondNodeInLevel, $this->thirdNodeInLevel);
     $q = new FlowQuery($context);
     $operation = new PrevOperation();
     $operation->evaluate($q, array());
     $output = $q->getContext();
     $this->assertEquals(array($this->firstNodeInLevel, $this->secondNodeInLevel), $output);
 }