Neos.ContentRepository/Classes/Command/NodeCommandControllerPlugin.php
protected function findMissingShadowNodesInWorkspace(Workspace $workspace, NodeType $nodeType = null)
    {
        $workspaces = array_merge([$workspace], $workspace->getBaseWorkspaces());

        $newShadowNodes = [];
        foreach ($workspaces as $workspace) {
            /** @var Workspace $workspace */
            if ($workspace->getBaseWorkspace() === null) {
                continue;
            }

            /** @var QueryBuilder $queryBuilder */
            $queryBuilder = $this->entityManager->createQueryBuilder();
            $queryBuilder->select('n')
                ->from(NodeData::class, 'n')
                ->where('n.workspace = :workspace');
            $queryBuilder->setParameter('workspace', $workspace->getName());
            if ($nodeType !== null) {
                $queryBuilder->andWhere('n.nodeType = :nodeType');
                $queryBuilder->setParameter('nodeType', $nodeType->getName());
            }

            /** @var NodeData $nodeData */
            foreach ($queryBuilder->getQuery()->getResult() as $nodeData) {
                $nodeDataSeenFromParentWorkspace = $this->nodeDataRepository->findOneByIdentifier($nodeData->getIdentifier(), $workspace->getBaseWorkspace(), $nodeData->getDimensionValues());
                // This is the good case, either the node does not exist or was shadowed
                if ($nodeDataSeenFromParentWorkspace === null) {
                    continue;
                }
                // Also good, the node was not moved at all.
                if ($nodeDataSeenFromParentWorkspace->getPath() === $nodeData->getPath()) {
                    continue;
                }

                $nodeDataOnSamePath = $this->nodeDataRepository->findOneByPath($nodeData->getPath(), $workspace->getBaseWorkspace(), $nodeData->getDimensionValues(), null);
                // We cannot just put a shadow node in the path, something exists, but that should be fine.
                if ($nodeDataOnSamePath !== null) {
                    continue;
                }
                $newShadowNodes[] = ['nodeData' => $nodeData, 'shadowPath' => $nodeDataSeenFromParentWorkspace->getPath()];
            }
        }

        return $newShadowNodes;
    }
protected function findMissingShadowNodesInWorkspace(Workspace $workspace, NodeType $nodeType = null)
    {
        $workspaces = array_merge([$workspace], $workspace->getBaseWorkspaces());

        $newShadowNodes = [];
        foreach ($workspaces as $workspace) {
            /** @var Workspace $workspace */
            if ($workspace->getBaseWorkspace() === null) {
                continue;
            }

            /** @var QueryBuilder $queryBuilder */
            $queryBuilder = $this->entityManager->createQueryBuilder();
            $queryBuilder->select('n')
                ->from(NodeData::class, 'n')
                ->where('n.workspace = :workspace');
            $queryBuilder->setParameter('workspace', $workspace->getName());
            if ($nodeType !== null) {
                $queryBuilder->andWhere('n.nodeType = :nodeType');
                $queryBuilder->setParameter('nodeType', $nodeType->getName());
            }

            /** @var NodeData $nodeData */
            foreach ($queryBuilder->getQuery()->getResult() as $nodeData) {
                $nodeDataSeenFromParentWorkspace = $this->nodeDataRepository->findOneByIdentifier($nodeData->getIdentifier(), $workspace->getBaseWorkspace(), $nodeData->getDimensionValues());
                // This is the good case, either the node does not exist or was shadowed
                if ($nodeDataSeenFromParentWorkspace === null) {
                    continue;
                }
                // Also good, the node was not moved at all.
                if ($nodeDataSeenFromParentWorkspace->getPath() === $nodeData->getPath()) {
                    continue;
                }

                $nodeDataOnSamePath = $this->nodeDataRepository->findOneByPath($nodeData->getPath(), $workspace->getBaseWorkspace(), $nodeData->getDimensionValues(), null);
                // We cannot just put a shadow node in the path, something exists, but that should be fine.
                if ($nodeDataOnSamePath !== null) {
                    continue;
                }
                $newShadowNodes[] = ['nodeData' => $nodeData, 'shadowPath' => $nodeDataSeenFromParentWorkspace->getPath()];
            }
        }

        return $newShadowNodes;
    }
protected function findMissingShadowNodesInWorkspace ( Workspace $ workspace , NodeType $ nodeType = null ) { $ workspaces = array_merge ( [ $ workspace ] , $ workspace -> getBaseWorkspaces ( ) ) ; $ newShadowNodes = [ ] ; foreach ( $ workspaces as $ workspace ) { /** @var Workspace $workspace */ if ( $ workspace -> getBaseWorkspace ( ) === null ) { continue ; } /** @var QueryBuilder $queryBuilder */ $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'n' ) -> from ( NodeData :: class , 'n' ) -> where ( 'n.workspace = :workspace' ) ; $ queryBuilder -> setParameter ( 'workspace' , $ workspace -> getName ( ) ) ; if ( $ nodeType !== null ) { $ queryBuilder -> andWhere ( 'n.nodeType = :nodeType' ) ; $ queryBuilder -> setParameter ( 'nodeType' , $ nodeType -> getName ( ) ) ; } /** @var NodeData $nodeData */ foreach ( $ queryBuilder -> getQuery ( ) -> getResult ( ) as $ nodeData ) { $ nodeDataSeenFromParentWorkspace = $ this -> nodeDataRepository -> findOneByIdentifier ( $ nodeData -> getIdentifier ( ) , $ workspace -> getBaseWorkspace ( ) , $ nodeData -> getDimensionValues ( ) ) ; // This is the good case, either the node does not exist or was shadowed if ( $ nodeDataSeenFromParentWorkspace === null ) { continue ; } // Also good, the node was not moved at all. if ( $ nodeDataSeenFromParentWorkspace -> getPath ( ) === $ nodeData -> getPath ( ) ) { continue ; } $ nodeDataOnSamePath = $ this -> nodeDataRepository -> findOneByPath ( $ nodeData -> getPath ( ) , $ workspace -> getBaseWorkspace ( ) , $ nodeData -> getDimensionValues ( ) , null ) ; // We cannot just put a shadow node in the path, something exists, but that should be fine. if ( $ nodeDataOnSamePath !== null ) { continue ; } $ newShadowNodes [ ] = [ 'nodeData' => $ nodeData , 'shadowPath' => $ nodeDataSeenFromParentWorkspace -> getPath ( ) ] ; } } return $ newShadowNodes ; }
Collects all nodes with missing shadow nodes

@param Workspace $workspace
@param NodeType $nodeType
@return array in the form [['nodeData' => <nodeDataInstance>, 'shadowPath' => '<shadowPath>'], ...]
Collects all nodes with missing shadow nodes