Neos\ContentRepository\Command\NodeCommandControllerPlugin::reorderChildNodesByNodeType PHP Метод

reorderChildNodesByNodeType() защищенный Метод

Reorder child nodes for the given node type
protected reorderChildNodesByNodeType ( string $workspaceName, boolean $dryRun, NodeType $nodeType ) : void
$workspaceName string
$dryRun boolean
$nodeType Neos\ContentRepository\Domain\Model\NodeType
Результат void
    protected function reorderChildNodesByNodeType($workspaceName, $dryRun, NodeType $nodeType)
    {
        $nodeTypes = $this->nodeTypeManager->getSubNodeTypes($nodeType->getName(), false);
        $nodeTypes[$nodeType->getName()] = $nodeType;
        if ($this->nodeTypeManager->hasNodeType((string) $nodeType)) {
            $nodeType = $this->nodeTypeManager->getNodeType((string) $nodeType);
            $nodeTypeNames[$nodeType->getName()] = $nodeType;
        } else {
            $this->output->outputLine('Node type "%s" does not exist', array((string) $nodeType));
            exit(1);
        }
        /** @var $nodeType NodeType */
        foreach ($nodeTypes as $nodeTypeName => $nodeType) {
            $childNodes = $nodeType->getAutoCreatedChildNodes();
            if ($childNodes === array()) {
                continue;
            }
            foreach ($this->getNodeDataByNodeTypeAndWorkspace($nodeTypeName, $workspaceName) as $nodeData) {
                /** @var NodeInterface $childNodeBefore */
                $childNodeBefore = null;
                $context = $this->nodeFactory->createContextMatchingNodeData($nodeData);
                $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
                if (!$node instanceof NodeInterface) {
                    continue;
                }
                foreach ($childNodes as $childNodeName => $childNodeType) {
                    $childNode = $node->getNode($childNodeName);
                    if ($childNode) {
                        if ($childNodeBefore) {
                            if ($dryRun === false) {
                                if ($childNodeBefore->getIndex() >= $childNode->getIndex()) {
                                    $childNode->moveAfter($childNodeBefore);
                                    $this->output->outputLine('Moved node named "%s" after node named "%s" in "%s"', array($childNodeName, $childNodeBefore->getName(), $node->getPath()));
                                }
                            } else {
                                $this->output->outputLine('Should move node named "%s" after node named "%s" in "%s"', array($childNodeName, $childNodeBefore->getName(), $node->getPath()));
                            }
                        }
                    } else {
                        $this->output->outputLine('Missing child node named "%s" in "%s".', array($childNodeName, $node->getPath()));
                    }
                    $childNodeBefore = $childNode;
                }
            }
        }
    }