{@inheritdoc}

@param FlowQuery $flowQuery the FlowQuery object
@param array $arguments the arguments for this operation
@return void
337011
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $term = isset($arguments[0]) ? $arguments[0] : null;
        $filterNodeTypeName = isset($arguments[1]) ? $arguments[1] : null;

        $nodeTypes = strlen($filterNodeTypeName) > 0 ? [$filterNodeTypeName] : array_keys($this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Document', false));

        /** @var NodeInterface $contextNode */
        $contextNode = $flowQuery->getContext()[0];

        $context = $contextNode->getContext();

        if ($term) {
            $matchedNodes = $this->nodeSearchService->findByProperties($term, $nodeTypes, $context, $contextNode);
        } else {
            $matchedNodes = [];
            // Yep, an internal API. But that's what we used in the old UI.
            $nodeDataRecords = $this->nodeDataRepository->findByParentAndNodeTypeRecursively($contextNode->getPath(), implode(',', $nodeTypes), $context->getWorkspace(), $context->getDimensions());
            foreach ($nodeDataRecords as $nodeData) {
                $matchedNode = $this->nodeFactory->createFromNodeData($nodeData, $context);
                if ($matchedNode !== null) {
                    $matchedNodes[$matchedNode->getPath()] = $matchedNode;
                }
            }
        }

        $flowQuery->setContext($matchedNodes);
    }
420
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $subject = $arguments[0];
        if (!isset($subject) || empty($subject)) {
            $flowQuery->setContext([]);
            return;
        }

        $filteredContext = [];
        $context = $flowQuery->getContext();
        if (is_string($subject)) {
            foreach ($context as $contextElement) {
                $contextElementQuery = new FlowQuery([$contextElement]);
                $contextElementQuery->pushOperation('children', $arguments);
                if ($contextElementQuery->count() > 0) {
                    $filteredContext[] = $contextElement;
                }
            }
        } else {
            if ($subject instanceof FlowQuery) {
                $elements = $subject->get();
            } elseif ($subject instanceof \Traversable) {
                $elements = iterator_to_array($subject);
            } elseif (is_object($subject)) {
                $elements = [$subject];
            } elseif (is_array($subject)) {
                $elements = $subject;
            } else {
                throw new FizzleException('supplied argument for has operation not supported', 1332489625);
            }
            foreach ($elements as $element) {
                if ($element instanceof TraversableNodeInterface) {
                    $parentsQuery = new FlowQuery([$element]);
                    foreach ($parentsQuery->parents([])->get() as $parent) {
                        /** @var TraversableNodeInterface $parent */
                        foreach ($context as $contextElement) {
                            /** @var TraversableNodeInterface $contextElement */
                            if ($contextElement === $parent) {
                                $filteredContext[] = $contextElement;
                            }
                        }
                    }
                }
            }
            $filteredContext = array_unique($filteredContext);
        }

        $flowQuery->setContext($filteredContext);
    }
179272
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $context = $flowQuery->getContext();
        if (isset($arguments[0])) {
            $index = $arguments[0];
            if (isset($context[$index])) {
                return $context[$index];
            } else {
                return null;
            }
        } else {
            return $context;
        }
    }
1315959
public function execute(string $view, array $arguments)
    {
        /**
         * @var Closure $sandbox
         * @var Context $content
         */

        /**
         * @param string $__flow__view
         *
         * @return string
         */
        $sandbox = function (string $__flow__view)
        {
            include $this->native->path($__flow__view);

            return $this->ext->blocks()->getExtends();
        };

        $content  = clone $this->content;
        $_view    = $view;
        $iterator = 0;

        $content->mergeData($arguments);

        do
        {
            if ($iterator >= $this->limit)
            {
                throw new Runtime('The application is not responding');
            }

            $iterator++;

            $_view = $sandbox->call(
                $content,
                $_view
            );
        }
        while ($_view);
    }
171758
public function displayQueries(array $queries = array(), $useColor = false, $useTemplate = false)
    {
        if (!$this->output) {
            throw new \RuntimeException('No output is defined');
        }
        $this->formatQueries($queries, $useColor);

        if ($useTemplate) {
            $content = $this->templateParser->parse($queries)->getContent();
        } else {

            $content = implode('', $queries);
        }

        $this->output->write($content);
    }
1231852
private function updateQueryTranslations(Query $query, array $translationsData): void
    {
        $mainLocale = $query->getMainLocale();

        foreach ($query->getAvailableLocales() as $locale) {
            if ($locale === $mainLocale) {
                continue;
            }

            if (!array_key_exists($locale, $translationsData)) {
                throw new RuntimeException(
                    sprintf('Could not find locale "%s" in the given query data', $locale)
                );
            }

            $this->updateQueryTranslation($query, $translationsData[$locale], $locale);
        }
    }
519658
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = [];
        $outputNodeAggregateIdentifiers = [];
        foreach ($flowQuery->getContext() as $contextNode) {
            /** @var TraversableNodeInterface $contextNode */
            $outputNodeAggregateIdentifiers[(string)$contextNode->getNodeAggregateIdentifier()] = true;
        }

        foreach ($flowQuery->getContext() as $contextNode) {
            try {
                $parentNode = $contextNode->findParentNode();
            } catch (NodeException $e) {
                continue;
            }

            foreach ($parentNode->findChildNodes() as $childNode) {
                if (!isset($outputNodeAggregateIdentifiers[(string)$childNode->getNodeAggregateIdentifier()])) {
                    $output[] = $childNode;
                    $outputNodeAggregateIdentifiers[(string)$childNode->getNodeAggregateIdentifier()] = true;
                }
            }
        }
        $flowQuery->setContext($output);

        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }
542232
public void createFlowConfig(FlowConfig flowConfig)
      throws RemoteInvocationException {
    LOG.debug("createFlowConfig with groupName " + flowConfig.getId().getFlowGroup() + " flowName " +
        flowConfig.getId().getFlowName());

    CreateIdRequest<ComplexResourceKey<FlowId, EmptyRecord>, FlowConfig> request =
        _flowconfigsRequestBuilders.create().input(flowConfig).build();
    ResponseFuture<IdResponse<ComplexResourceKey<FlowId, EmptyRecord>>> flowConfigResponseFuture =
        _restClient.get().sendRequest(request);

    flowConfigResponseFuture.getResponse();
  }
1218563
public function sendWriteQuery($query, array $parameters = array())
    {
        return $this->sendCypherQuery($query, $parameters, $this->getWriteConnection()->getAlias(), self::WRITE_QUERY);
    }
484412
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = [];
        $outputNodeIdentifiers = [];
        $until = [];

        foreach ($flowQuery->getContext() as $contextNode) {
            $nextNodes = $this->getNextForNode($contextNode);
            if (isset($arguments[0]) && !empty($arguments[0])) {
                $untilQuery = new FlowQuery($nextNodes);
                $untilQuery->pushOperation('filter', [$arguments[0]]);

                $until = $untilQuery->get();
            }

            if (isset($until[0]) && !empty($until[0])) {
                $nextNodes = $this->getNodesUntil($nextNodes, $until[0]);
            }

            foreach ($nextNodes as $nextNode) {
                if ($nextNode !== null && !isset($outputNodeIdentifiers[(string)$nextNode->getNodeAggregateIdentifier()])) {
                    $outputNodeIdentifiers[(string)$nextNode->getNodeAggregateIdentifier()] = true;
                    $output[] = $nextNode;
                }
            }
        }

        $flowQuery->setContext($output);

        if (isset($arguments[1]) && !empty($arguments[1])) {
            $flowQuery->pushOperation('filter', [$arguments[1]]);
        }
    }
660929
public function run($data, string $node, string $port): NetworkInterface
    {
        if (empty($this->graph)) {
            throw new FlowException(
                "Graph is not yet initialized!"
            );
        }

        $this->graph->addInitial($data, $node, $port);

        return $this;
    }
727661
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        if (!isset($arguments[0]) || empty($arguments[0])) {
            return;
        }

        if ($arguments[0] instanceof NodeInterface) {
            $filteredContext = [];
            $context = $flowQuery->getContext();
            foreach ($context as $element) {
                if ($element === $arguments[0]) {
                    $filteredContext[] = $element;
                    break;
                }
            }
            $flowQuery->setContext($filteredContext);
        } else {
            parent::evaluate($flowQuery, $arguments);
        }
    }
865581
protected function setRange($arguments)
    {
        $this->query->setStart($this->getOffset($arguments));
        $this->query->setRows($this->getCount($arguments));
    }
613072
private function setQueryParameters(TransportRequestInterface $transportRequest, $parameters)
    {
        if(!empty($parameters) && is_array($parameters)) {
            $transportRequest->setQueryParams($parameters);
        }

        return $transportRequest;
    }
1132294
public function suggestQuery($arguments)
    {
        $this->query = $this->getConnection()->createSuggester();
        $results = [];
        if (array_key_exists('q', $arguments)) {
            $this->query->setQuery($arguments['q']);
            if ($arguments['dictionary']) {
                $this->query->setDictionary($arguments['dictionary']);
            }

            $this->addFacetFilters($arguments);
            $solrResults = $this->getConnection()->execute($this->query)->getResults();
            foreach ($solrResults as $suggestions) {
                $results = array_merge($results, $suggestions->getSuggestions());
            }
        } else {
            // TODO: Error message in JSON?
        }

        return $results;
    }
769738
protected function _setQuery(string $type, $args): self
    {
        if (!\is_array($args) && !($args instanceof AbstractSpanQuery)) {
            throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractSpanQuery');
        }

        return $this->setParam($type, $args);
    }
515071
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $sortOrder = 'ASC';
        if (!empty($arguments[0]) && in_array($arguments[0], ['ASC', 'DESC'], true)) {
            $sortOrder = $arguments[0];
        }
        
        $nodes = $flowQuery->getContext();

        $indexPathCache = [];

        /** @var NodeInterface $node */
        foreach ($nodes as $node) {
            // Collect the list of sorting indices for all parents of the node and the node itself
            $nodeIdentifier = $node->getIdentifier();
            $indexPath = [$node->getIndex()];
            while ($node = $node->getParent()) {
                $indexPath[] = $node->getIndex();
            }
            $indexPathCache[$nodeIdentifier] = $indexPath;
        }

        $flip = $sortOrder === 'DESC' ? -1 : 1;

        usort($nodes, function (NodeInterface $a, NodeInterface $b) use ($indexPathCache, $flip) {
            if ($a === $b) {
                return 0;
            }

            // Compare index path starting from the site root until a difference is found
            $aIndexPath = $indexPathCache[$a->getIdentifier()];
            $bIndexPath = $indexPathCache[$b->getIdentifier()];
            while (count($aIndexPath) > 0 && count($bIndexPath) > 0) {
                $diff = (array_pop($aIndexPath) - array_pop($bIndexPath));
                if ($diff !== 0) {
                    return $flip * $diff < 0 ? -1 : 1;
                }
            }

            return 0;
        });

        $flowQuery->setContext($nodes);
    }