Returns children of given node.

@param NodeInterface $node

@return NodeInterface[]
979662
private function getChildren(NodeInterface $node)
    {
        $result = [];
        foreach ($node->getNodes() as $child) {
            $result[$child->getIdentifier()] = $child;
        }

        return $result;
    }
53130
public static function findClassLikeNodes(array $nodes): array
    {
        $collectedNodes = [];

        foreach ($nodes as $node) {
            if ($node instanceof Node\Stmt\ClassLike) {
                $collectedNodes[] = $node;
            } elseif ($node instanceof Use_) {
                continue;
            } elseif (is_array($node)) {
                $collectedNodes = array_merge(
                    static::findClassLikeNodes($node),
                    $collectedNodes
                );
            } elseif ($node instanceof Node) {
                $collectedNodes = array_merge(
                    static::findClassLikeNodes(static::getSubNodes($node)),
                    $collectedNodes
                );
            }
        }

        return $collectedNodes;
    }
1222429
protected function optimizeNodes(ChildrenNodeCollection $nodes)
    {
        $optimizedNodes = [];

        foreach ($nodes->getChildren() as $key => $node) {
            $optimizedNodes[$key] = $this->optimizeNode($node);
        }

        $optimizedNodes = new ChildrenNodeCollection($optimizedNodes);

        $optimizedNodes = $this->moveCommonMatchersToParentNode($optimizedNodes);

        return $optimizedNodes;
    }
938072
public function createForNode(NodeInterface $node)
    {
        $site = $this->siteRepository->findOneBySiteId($node->getSiteId());
        $nodes = $this->nodeRepository->findPublishedByPathAndLanguage($node->getPath(), $site->getSiteId(), $node->getLanguage());

        $routePattern = $this->nodeRepository->findAllRoutePattern($node->getLanguage(), $site->getSiteId());
        $routePattern = $this->computeRoutePattern($routePattern);
        $routes = array();

        foreach ($nodes as $node) {
            $routes = array_merge($this->generateRoutesForNode($node, $site, $routePattern), $routes);
        }

        return $routes;
    }
201188
public function sort(TreeNodeInterface $node)
    {
        if (!$node->getTree()->hasChildren($node)) {
            return array();
        }

        $parentId = $node->getId();
        $sortMode = $node->getSortMode();
        $sortDir = $node->getSortDir();

        $queryBuilder = $this->connection->createQueryBuilder();
        $queryBuilder
            ->select('t.id')
            ->from('tree', 't')
            ->where($queryBuilder->expr()->eq('t.parent_id', $parentId));

        switch ($sortMode) {
            case TreeInterface::SORT_MODE_TITLE:
                $queryBuilder
                    ->addSelect('evmf.backend AS sorter')
                    ->leftJoin('t', 'element', 'e', 't.type_id = e.eid')
                    ->leftJoin('e', 'element_version', 'ev', 'e.eid = ev.eid AND e.latest_version = ev.version')
                    ->leftJoin('ev', 'element_version_mapped_field', 'evmf', 'ev.id = evmf.element_version_id AND evmf.language = '.$this->connection->quote($this->sortLanguage))
                    ->orderBy('evmf.backend', $sortDir);
                break;

            case TreeInterface::SORT_MODE_CREATEDATE:
                $queryBuilder
                    ->addSelect('t.modify_time AS sorter')
                    ->orderBy('t.modify_time', $sortDir);
                break;

            case TreeInterface::SORT_MODE_PUBLISHDATE:
                $queryBuilder
                    ->addSelect('to.publish_time AS sorter')
                    ->leftJoin('t', 'tree_online', 'to', 'eto.tree_id = et.id AND eto.language = '.$this->connection->quote($this->sortLanguage))
                    ->orderBy('to.publish_time', $sortDir);
                break;

            case TreeInterface::SORT_MODE_CUSTOMDATE:
                $queryBuilder
                    ->addSelect('evmf.date AS sorter')
                    ->leftJoin('t', 'element', 'e', 't.type_id = e.eid')
                    ->leftJoin('e', 'element_version', 'ev', 'e.eid = ev.eid AND e.latest_version = ev.version')
                    ->leftJoin('ev', 'element_version_mapped_field', 'evmf', 'ev.id = evmf.element_version_id AND evmf.language = '.$this->connection->quote($this->sortLanguage))
                    ->orderBy('evmf.date', $sortDir);
                break;

            default:
                $queryBuilder
                    ->addSelect('t.sort AS sorter')
                    ->orderBy('t.sort', 'ASC');
                break;
        }

        $result = $this->connection->fetchAll($queryBuilder->getSQL());
        $result = array_column($result, 'id');

        return $result;
    }
481147
public function addChild(NodeInterface $node)
    {
        $name = $node->getName();
        if (!\strlen($name)) {
            throw new \InvalidArgumentException('Child nodes must be named.');
        }
        if (isset($this->children[$name])) {
            throw new \InvalidArgumentException(sprintf('A child node named "%s" already exists.', $name));
        }

        $this->children[$name] = $node;
    }
1166634
public function getLanguagesForNode(NodeInterface $node)
    {
        $languages = [];
        foreach ($node->getProperties() as $property) {
            /* @var PropertyInterface $property */
            preg_match('/^' . $this->languageNamespace . ':([a-zA-Z_]*?)-changer/', $property->getName(), $matches);

            if ($matches) {
                $languages[$matches[1]] = $matches[1];
            }
        }

        return array_values($languages);
    }
953976
public function getNodeMeta(NodeInterface $node) : array
    {
        if ($this->isNodeBlacklisted($node)) {
            return [];
        }

        return (array)$this->database->query("SELECT meta_title AS title, meta_description AS description FROM {ucms_seo_node} WHERE nid = ?", [$node->id()])->fetchAssoc();
    }
24740
public function getChilds($id)
    {
        $result = [];
        if (array_key_exists($id, $this->finder)) {
            return $this->recursiveGetChilds($this->finder[$id][$this->config['childs']], $result);
        } else {
            return $result;
        }
    }
928832
public function getStructureTypeForNode(NodeInterface $node)
    {
        $mixinTypes = $node->getPropertyValueWithDefault('jcr:mixinTypes', []);

        if (in_array('sulu:' . Structure::TYPE_PAGE, $mixinTypes)) {
            return Structure::TYPE_PAGE;
        }

        if (in_array('sulu:' . Structure::TYPE_SNIPPET, $mixinTypes)) {
            return Structure::TYPE_SNIPPET;
        }

        return;
    }
833540
public function addNode(NodeInterface $node)
    {
        if ($this->checkChildNode($node)) {
            $this->nodes->add($node);

            $node->setPosition(count($this->getNodes()));
            $node->setParent($this);
        }

        return $this;
    }
122748
protected function renderChildrenInformation(NodeInterface $node, string $nodeTypeFilterString): array
    {
        $documentChildNodes = $node->getChildNodes($nodeTypeFilterString);
        // child nodes for content tree, must not include those nodes filtered out by `baseNodeType`
        $contentChildNodes = $node->getChildNodes($this->buildContentChildNodeFilterString());
        $childNodes = array_merge($documentChildNodes, $contentChildNodes);

        $mapper = function (NodeInterface $childNode) {
            return [
                'contextPath' => $childNode->getContextPath(),
                'nodeType' => $childNode->getNodeType()->getName() // TODO: DUPLICATED; should NOT be needed!!!
            ];
        };

        return array_map($mapper, $childNodes);
    }
454800
public function getChildren(Node $node, $includeHiddenFromNav = true)
    {
        $this->init();
        $children = array();

        if (array_key_exists($node->getId(), $this->childNodes)) {
            $nodes = $this->childNodes[$node->getId()];
            /* @var Node $childNode */
            foreach ($nodes as $childNode) {
                $nodeTranslation = $childNode->getNodeTranslation(
                    $this->locale,
                    $this->includeOffline
                );
                if (!is_null($nodeTranslation)) {
                    $children[] = new NodeMenuItem(
                        $childNode,
                        $nodeTranslation,
                        false,
                        $this
                    );
                }
            }

            $children = array_filter(
                $children,
                function (NodeMenuItem $entry) use ($includeHiddenFromNav) {
                    if ($entry->getNode()->isHiddenFromNav(
                        ) && !$includeHiddenFromNav
                    ) {
                        return false;
                    }

                    return true;
                }
            );
        }

        return $children;
    }
903181
public function initializeAreasNode(NodeInterface $node)
    {
        $site = $this->siteRepository->findOneBySiteId($node->getSiteId());
        $templateSet = $site->getTemplateSet();
        $areasName = $this->templateManager->getTemplateAreas($node->getTemplate(), $templateSet);
        foreach($areasName as $areaName) {
            if (! $node->getArea($areaName) instanceof AreaInterface) {
                $node->setArea($areaName, new $this->areaClass());
            }
        }

        return $node;
    }
739564
public static function get_ancestors( \DOMNode $node ) {
		$result = [];

		while ( ( $node = $node->parentNode ) && ( $node instanceof \DOMElement ) ) { // phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
			$result[] = $node;
		}

		return $result;
	}
63453
private function getCategories(NodeInterface $node, $locale)
    {
        return $node->getPropertyValueWithDefault(
            sprintf(self::CATEGORIES_PROPERTY, $locale),
            []
        );
    }
1017940
protected function nodeToDictionary( Node $node )
    {
        $result = $node->attributes;

        $containerKeys = [];

        foreach ($node->children as $child) {
            $arrayChild = $this->nodeToDictionary($child);

            $childName = $child->name;
            $childValue = $arrayChild;

            if (sizeof($child->children) == 0) {
                $childValue = $child->text;
            }

            if (isset( $result[ $childName ] )) {
                if (!in_array($childName, $containerKeys)) {
                    $result[ $childName ] = [$result[ $childName ]];
                    $containerKeys[] = $childName;
                }

                $result[ $childName ][] = $childValue;
            } else {
                $result[ $childName ] = $childValue;
            }
        }

        return $result;
    }