Visit the node and update the query.

@param mixed                              $query
@param \Railken\SQ\Contracts\NodeContract $node
@param string                             $context
172298
public function visit($query, $node, string $context)
    {
        if ($node instanceof $this->node) {
            $child0 = $node->getChildByIndex(0);
            $child1 = $node->getChildByIndex(1);

            if ($context === Nodes\OrNode::class) {
                $query->orWhere($this->parseNode($query, $child0), $this->operator, $this->parseNode($query, $child1));
            }

            if ($context === Nodes\AndNode::class) {
                $query->where($this->parseNode($query, $child0), $this->operator, $this->parseNode($query, $child1));
            }
        }
    }
385206
public function buildQuery($query)
    {
        $q = $this->request->getQuery();

        foreach ($query as $key => $value)
        {
            $q[$key] = $value;
        }
    }
185914
public function execute($query = null)
    {
        try {
            $event = new ConnectionEvent($this, $query);
            $this->container->getDispatcher()->dispatch(ConnectionEvent::ON_QUERY, $event);
            $this->affectedRows = parent::exec($query);
        } catch (\Exception $exception) {
            throw new ConnectionException('Executing query has error: [:code] ":error"', [
                'code'  => $exception->getCode(),
                'error' => $exception->getMessage(),
            ]);
        }
        
        return $this;
    }
1101520
public function execute($query)
    {
        $context = $this->getCommandContext();

        $context->query = $query;

        if ($this->getCommandChain()->run('before.execute', $context) !== false) {
            $context->result = $this->_adapter->execute(to_str($context->query));
            $this->getCommandChain()->run('after.execute', $context);
        }

        return $context->result;
    }
547220
public function enterNode(Node $node)
    {
        if ($this->atLeastPhp55) {
            return;
        }

        if (!$node instanceof Empty_) {
            return;
        }

        if (!$node->expr instanceof Variable) {
            $msg = \sprintf('syntax error, unexpected %s', $this->getUnexpectedThing($node->expr));

            throw new ParseErrorException($msg, $node->expr->getLine());
        }
    }
166672
protected function setJoin(Query $query = null)
    {
        $query = $query ?: $this->query;

        $foreignKey = $this->relatedMap->getTable().'.'.$this->secondKey;

        $query->join($this->parentMap->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey);
    }
744583
public function resolveNextNode(NodeContract $node, NodeContract $new_node)
    {
        if ($new_node->next() === null) {
            throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
        }

        // Nothing ...
        if (!$new_node->getParent() || ($new_node->next() instanceof Nodes\GroupNode)) {
            $children = [];

            foreach ($new_node->next()->getChildren() as $child) {
                if (!(trim($child->getValue()) === ',' && $child instanceof Nodes\TextNode)) {
                    $children[] = $child;
                }
            }

            $new_node->setChildren($children);

            if ($new_node->getParent() !== null) {
                $new_node->getParent()->removeChild($new_node->next());
            }
        } else {
            throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
        }
    }
785969
private static function complete($node, $currentcontextlevel = false, $currentcontextid = false) {
        if (!isset($node['active'])) {
            if ($currentcontextlevel && !empty($node['contextlevel']) &&
                    $currentcontextlevel == $node['contextlevel'] &&
                    empty($currentcontextid)) {
                // This is the active context level, we also checked that there
                // is no default contextid set.
                $node['active'] = true;
            } else if ($currentcontextid && !empty($node['contextid']) &&
                    $currentcontextid == $node['contextid']) {
                $node['active'] = true;
            } else {
                $node['active'] = null;
            }
        }

        if (!isset($node['branches'])) {
            $node['branches'] = [];
        } else {
            foreach ($node['branches'] as $key => $childnode) {
                $node['branches'][$key] = self::complete($childnode, $currentcontextlevel, $currentcontextid);
            }
        }

        if (!isset($node['expandelement'])) {
            $node['expandelement'] = null;
        }

        if (!isset($node['expandcontextid'])) {
            $node['expandcontextid'] = null;
        }

        if (!isset($node['contextid'])) {
            $node['contextid'] = null;
        }

        if (!isset($node['contextlevel'])) {
            $node['contextlevel'] = null;
        }

        if (!isset($node['expanded'])) {
            if (!empty($node['branches'])) {
                $node['expanded'] = 1;
            } else {
                $node['expanded'] = 0;
            }
        }
        return $node;
    }
826198
protected function removeNodes(DOMDocument $ir, $query, DOMNode $contextNode = null)
	{
		foreach ($this->query($query, $contextNode) as $node)
		{
			if ($node->parentNode instanceof DOMElement)
			{
				$node->parentNode->removeChild($node);
			}
		}
	}
869741
protected function modifyRelationQueryForContext(Model $model, $query)
    {
        /** @var Relation $relation */
        $information = $this->getInformationRepository()->getByModel($model);

        if ( ! $information) {
            return $query;
        }

        // Deal with global scopes, if any
        $disableScopes = $information->meta->disable_global_scopes;

        if (true === $disableScopes || is_array($disableScopes)) {
            $query->withoutGlobalScopes(
                true === $disableScopes ? null : $disableScopes
            );
        }

        // Apply repository context, if any
        $strategy = $information->meta->repository_strategy;

        if ($strategy) {
            $strategy = $this->resolveContextStrategy($strategy);

            if ($strategy) {
                $query = $strategy->apply($query, $information);
            }
        }

        return $query;
    }
132363
public function build($query, NodeContract $node, $context = Nodes\AndNode::class)
    {
        foreach ($this->visitors as $visitor) {
            $visitor->visit($query, $node, $context);
        }
    }
620323
public function visit($query, NodeContract $node, string $context)
    {
        if ($node instanceof Nodes\AndNode) {
            $callback = function ($q) use ($node) {
                foreach ($node->getChildren() as $child) {
                    if ($child instanceof Nodes\KeyNode || $child instanceof Nodes\ValueNode) {
                        throw new \Railken\SQ\Exceptions\QuerySyntaxException();
                    }

                    $this->getBuilder()->build($q, $child, Nodes\AndNode::class);
                }
            };

            $context === Nodes\OrNode::class && $query->orWhere($callback);
            $context === Nodes\AndNode::class && $query->where($callback);
        }
    }
812575
public function visit($query, $node, string $context)
    {
        if ($node instanceof $this->node) {
            $column = null;
            $values = null;

            if ($node->getChildByIndex(0) instanceof Nodes\KeyNode) {
                $column = $this->parseKey($node->getChildByIndex(0)->getValue());
            }

            if ($node->getChildByIndex(1) instanceof Nodes\GroupNode) {
                $values = array_map(function ($node) {
                    return $this->parseValue($node->getValue());
                }, $node->getChildByIndex(1)->getChildren());
            }

            if ($column && $values) {
                $context === Nodes\OrNode::class && $query->orWhereIn($column, $values);
                $context === Nodes\AndNode::class && $query->whereIn($column, $values);
            }
        }
    }
470911
protected function xpath($query, DOMNode $node = null)
	{
		$query = str_replace('$XSL', '"' . self::XMLNS_XSL . '"', $query);

		return iterator_to_array($this->xpath->query($query, $node));
	}
1080723
function(context, node) {
        var layerContext = {
            visibility: (node.getAttribute("hidden") != "1"),
            queryable: (node.getAttribute("queryable") == "1"),
            formats: [],
             styles: [],
             metadata: {}
        };

        this.runChildNodes(layerContext, node);
        // set properties common to multiple objects on layer options/params
        context.layersContext.push(layerContext);
    }
249295
protected function updateWorkspaceInfo(string $documentNodeContextPath)
    {
        $updateWorkspaceInfo = new UpdateWorkspaceInfo();
        $documentNode = $this->nodeService->getNodeFromContextPath($documentNodeContextPath, null, null, true);
        $updateWorkspaceInfo->setWorkspace(
            $documentNode->getContext()->getWorkspace()
        );

        $this->feedbackCollection->add($updateWorkspaceInfo);
    }
243444
protected function _afterRepositoryDeletenodes(AnCommandContext $context)
    {
        parent::_afterRepositoryDeletenodes($context);

        $this->_getRepositoryForTable('todos_todos')
             ->update(array('open_status_change_by' => null),
                      array('node_id' => $context['node_ids']));
    }