Neos\Neos\Eel\FlowQueryOperations\ParentsUntilOperation::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) {
            $siteNode = $contextNode->getContext()->getCurrentSiteNode();
            $parentNodes = $this->getParents($contextNode, $siteNode);
            if (isset($arguments[0]) && !empty($arguments[0] && isset($parentNodes[0]))) {
                $untilQuery = new FlowQuery(array($parentNodes[0]));
                $untilQuery->pushOperation('closest', array($arguments[0]));
                $until = $untilQuery->get();
            }
            if (isset($until) && is_array($until) && !empty($until) && isset($until[0])) {
                $parentNodes = $this->getNodesUntil($parentNodes, $until[0]);
            }
            if (is_array($parentNodes)) {
                foreach ($parentNodes as $parentNode) {
                    if ($parentNode !== null && !isset($outputNodePaths[$parentNode->getPath()])) {
                        $outputNodePaths[$parentNode->getPath()] = true;
                        $output[] = $parentNode;
                    }
                }
            }
        }
        $flowQuery->setContext($output);
        if (isset($arguments[1]) && !empty($arguments[1])) {
            $flowQuery->pushOperation('filter', $arguments[1]);
        }
    }