Neos.ContentRepository/Classes/Command/NodeCommandControllerPlugin.php
protected function reorderChildNodesByNodeType($workspaceName, /** @noinspection PhpUnusedParameterInspection */$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->dispatch(self::EVENT_ERROR, sprintf('Node type "<i>%s</i>" does not exist', $nodeType));
            return;
        }

        /** @var $nodeType NodeType */
        foreach ($nodeTypes as $nodeTypeName => $nodeType) {
            $childNodes = $nodeType->getAutoCreatedChildNodes();
            if ($childNodes === []) {
                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 && $childNodeBefore->getIndex() >= $childNode->getIndex()) {
                            $taskDescription = sprintf('Move node named "<i>%s</i>" after node named "<i>%s</i>" in "<i>%s</i>"', $childNodeName, $childNodeBefore->getName(), $node->getPath());
                            $taskClosure = function () use ($childNode, $childNodeBefore) {
                                $childNode->moveAfter($childNodeBefore);
                            };
                            $this->dispatch(self::EVENT_TASK, $taskDescription, $taskClosure);
                        }
                    } else {
                        $this->dispatch(self::EVENT_NOTICE, sprintf('Missing child node named "<i>%s</i>" in "<i>%s</i>".', $childNodeName, $node->getPath()));
                    }

                    $childNodeBefore = $childNode;
                }
            }
        }
    }
protected function reorderChildNodesByNodeType($workspaceName, /** @noinspection PhpUnusedParameterInspection */$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->dispatch(self::EVENT_ERROR, sprintf('Node type "<i>%s</i>" does not exist', $nodeType));
            return;
        }

        /** @var $nodeType NodeType */
        foreach ($nodeTypes as $nodeTypeName => $nodeType) {
            $childNodes = $nodeType->getAutoCreatedChildNodes();
            if ($childNodes === []) {
                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 && $childNodeBefore->getIndex() >= $childNode->getIndex()) {
                            $taskDescription = sprintf('Move node named "<i>%s</i>" after node named "<i>%s</i>" in "<i>%s</i>"', $childNodeName, $childNodeBefore->getName(), $node->getPath());
                            $taskClosure = function () use ($childNode, $childNodeBefore) {
                                $childNode->moveAfter($childNodeBefore);
                            };
                            $this->dispatch(self::EVENT_TASK, $taskDescription, $taskClosure);
                        }
                    } else {
                        $this->dispatch(self::EVENT_NOTICE, sprintf('Missing child node named "<i>%s</i>" in "<i>%s</i>".', $childNodeName, $node->getPath()));
                    }

                    $childNodeBefore = $childNode;
                }
            }
        }
    }
protected function reorderChildNodesByNodeType ( $ workspaceName , /** @noinspection PhpUnusedParameterInspection */ $ 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 -> dispatch ( self :: EVENT_ERROR , sprintf ( 'Node type "<i>%s</i>" does not exist' , $ nodeType ) ) ; return ; } /** @var $nodeType NodeType */ foreach ( $ nodeTypes as $ nodeTypeName => $ nodeType ) { $ childNodes = $ nodeType -> getAutoCreatedChildNodes ( ) ; if ( $ childNodes === [ ] ) { 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 && $ childNodeBefore -> getIndex ( ) >= $ childNode -> getIndex ( ) ) { $ taskDescription = sprintf ( 'Move node named "<i>%s</i>" after node named "<i>%s</i>" in "<i>%s</i>"' , $ childNodeName , $ childNodeBefore -> getName ( ) , $ node -> getPath ( ) ) ; $ taskClosure = function ( ) use ( $ childNode , $ childNodeBefore ) { $ childNode -> moveAfter ( $ childNodeBefore ) ; } ; $ this -> dispatch ( self :: EVENT_TASK , $ taskDescription , $ taskClosure ) ; } } else { $ this -> dispatch ( self :: EVENT_NOTICE , sprintf ( 'Missing child node named "<i>%s</i>" in "<i>%s</i>".' , $ childNodeName , $ node -> getPath ( ) ) ) ; } $ childNodeBefore = $ childNode ; } } } }
Reorder child nodes for the given node type

@param string $workspaceName
@param boolean $dryRun (unused)
@param NodeType $nodeType
@return void
@throws NodeTypeNotFoundException
@throws NodeConfigurationException
Reorder child nodes for the given node type