{@inheritdoc}

@param FlowQuery $flowQuery the FlowQuery object
@param array $arguments the context index to fetch from
@return mixed
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;
        }
    }
1353159
public function statement($query, $bindings = [])
    {
        if (!empty($bindings)) {
            return $this->client->runQuery($query, ['arguments' => $bindings]);
        } else {
            return $this->client->runQuery($query);
        }
    }
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;
    }
93401
public function triggerFlow(array $flow, ...$args)
    {
        foreach ($flow as $i => $step) {
            //subflows will trigger separately
            if (is_array($step)) {
                continue;
            }

            //rule the subtasks first
            $j = 1;

            while (isset($flow[$i + $j]) && is_array($flow[$i + $j])) {
                //subflows should have
                //an event and a handler
                if (count($flow[$i + $j]) > 1) {
                    //the subflow is valid
                    //extract the event out
                    $event = array_shift($flow[$i + $j]);
                    self::$flows[$event] = $flow[$i + $j];
                }

                $j++;
            }

            //now trigger the event
            $this->trigger($step, ...$args);

            self::$flows = [];

            //analyze the meta
            $meta = $this->getEventHandler()->getMeta();

            //if status is incomplete
            if ($meta === EventHandler::STATUS_INCOMPLETE) {
                //we should also stop the flow
                break;
            }
        }

        return $this;
    }
1037099
public function query($query) {
		$args = func_get_args();
		$query = array_shift($args);
		return $this->execute($query, $args);
	}
1371641
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $parents = [];
        $parentNodeAggregateIdentifiers = [];
        /* @var TraversableNodeInterface $contextNode */
        foreach ($flowQuery->getContext() as $contextNode) {
            $node = $contextNode;
            while (!$node->isRoot()) {
                $node = $node->findParentNode();
                if (isset($parentNodeAggregateIdentifiers[(string)$node->getNodeAggregateIdentifier()])) {
                    continue;
                }
                $parents[] = $node;
                $parentNodeAggregateIdentifiers[(string)$node->getNodeAggregateIdentifier()] = true;
            }
        }

        $flowQuery->setContext($parents);

        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }
199504
public function query(array $arguments = [])
    {
        $adaptees = get_terms(['taxonomy' => $this->getSlug()]);

        return $this->plugger
            ->setModel($this)
            ->setAdapter(Term::class)
            ->plugIn($adaptees)
            ->getConnected();
    }
1241651
public function get($key)
    {
        if (!array_key_exists($key, $this->flowObjects)) {
            return null;
        }

        return $this->flowObjects[$key];
    }
116743
public function call($name, $arguments = [])
    {
        return $this->runViaLaravelCollection(function ($collection) use (
            $name,
            $arguments
        ) {
            return call_user_func_array(
                [$collection, $name],
                $this->coollectizeCallbacks($this->__toArray($arguments), $name)
            );
        },
        $name);
    }
164513
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $parents = [];
        /* @var TraversableNodeInterface $contextNode */
        foreach ($flowQuery->getContext() as $contextNode) {
            $node = $contextNode;
            do {
                try {
                    $node = $node->findParentNode();
                } catch (NodeException $exception) {
                    break;
                }
                // stop at sites
                if ($node->findNodePath() == SiteService::SITES_ROOT_PATH) {
                    break;
                }
                $parents[] = $node;
            } while (true);
        }

        $flowQuery->setContext($parents);

        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }
1007056
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = [];
        $outputNodePaths = [];

        $filter = isset($arguments[0]) ? $arguments[0] : null;

        /** @var NodeInterface $contextNode */
        foreach ($flowQuery->getContext() as $contextNode) {
            /** @var NodeInterface $childNode */
            foreach ($contextNode->getChildNodes($filter) as $childNode) {
                if (!isset($outputNodePaths[$childNode->getPath()])) {
                    $output[] = $childNode;
                    $outputNodePaths[$childNode->getPath()] = true;
                }
            }
        }
        $flowQuery->setContext($output);
    }
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);
    }
1137414
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $output = [];
        $outputNodeAggregateIdentifiers = [];
        foreach ($flowQuery->getContext() as $contextNode) {
            $prevNode = $this->getPrevForNode($contextNode);
            if ($prevNode !== null && !isset($outputNodeAggregateIdentifiers[(string)$prevNode->getNodeAggregateIdentifier()])) {
                $outputNodeAggregateIdentifiers[(string)$prevNode->getNodeAggregateIdentifier()] = true;
                $output[] = $prevNode;
            }
        }
        $flowQuery->setContext($output);

        if (isset($arguments[0]) && !empty($arguments[0])) {
            $flowQuery->pushOperation('filter', $arguments);
        }
    }
1185054
public function pushQuery($query, array $parameters = array())
    {
        $this->checkIfOpened();
        try {
            $response = $this->handleResponse($this->client->pushToTransaction($this->transactionId, $query, $parameters, $this->conn));
            $result = $response->getResult();
            $this->results[] = $result;

            return $result;
        } catch(HttpException $e) {
            $this->rollback();
            throw $e;
        }

    }
545917
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        if (!isset($arguments[0]) || empty($arguments[0])) {
            throw new FlowQueryException('closest() requires a filter argument', 1332492263);
        }

        $output = [];
        foreach ($flowQuery->getContext() as $contextNode) {
            $contextNodeQuery = new FlowQuery([$contextNode]);
            $contextNodeQuery->pushOperation('first', []);
            $contextNodeQuery->pushOperation('filter', $arguments);

            $parentsQuery = new FlowQuery([$contextNode]);
            $contextNodeQuery->pushOperation('add', [$parentsQuery->parents($arguments[0])->get()]);

            foreach ($contextNodeQuery as $result) {
                /* @var TraversableNodeInterface $result */
                $output[(string)$result->getNodeAggregateIdentifier()] = $result;
            }
        }

        $flowQuery->setContext(array_values($output));
    }
1157849
public function getFunction($type, array $args = [])
    {
        $className = null;
        if (array_key_exists($type, $this->functions)) {
            $className = $this->functions[$type];
        } elseif (array_key_exists(static::CLASS_NAME, $args)) {
            $className = $args[static::CLASS_NAME];
        }

        if (null === $className) {
            $type = (string)$type;
            $errMsg = sprintf(
                'Нет типа(%s) или аргумента class.name',
                $type
            );
            throw new WorkflowException($errMsg);
        }

        if (!class_exists($className)) {
            $errMsg = sprintf(
                'Отсутствует класс %s',
                $className
            );
            throw new WorkflowException($errMsg);
        }

        $function = new $className();

        if (!$function instanceof FunctionProviderInterface) {
            $errMsg = sprintf(
                'Function должен реализовывать интерфейс %s',
                FunctionProviderInterface::class
            );
            throw new WorkflowException($errMsg);
        }

        return $function;
    }
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);
        }
    }