src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/PasteAllHandler.php
protected function getHierarchyCollection(array $clipboardItems, EnvironmentInterface $environment)
    {
        $dataProvider   = $environment->getDataProvider();
        $inputProvider  = $environment->getInputProvider();
        $dataDefinition = $environment->getDataDefinition();
        $relationShip   = $dataDefinition->getModelRelationshipDefinition();
        $childCondition = $relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName());

        $collection = [];

        $originalPasteMode = $inputProvider->hasParameter('after') ? 'after' : 'into';

        $previousItem = null;
        foreach ($clipboardItems as $clipboardItem) {
            $modelId = $clipboardItem->getModelId();
            if (!$modelId
                || \array_key_exists($modelId->getSerialized(), $collection)
            ) {
                continue;
            }

            $pasteMode  = $previousItem ? 'after' : $originalPasteMode;
            $pasteAfter =
                $previousItem ? $previousItem->getModelId()->getSerialized() : $inputProvider->getParameter($pasteMode);

            $collection[$modelId->getSerialized()] = [
                'item'       => $clipboardItem,
                'pasteAfter' => $pasteAfter,
                'pasteMode'  => $pasteMode
            ];

            $previousItem = $clipboardItem;

            $model =
                $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));

            $itemCollection =
                $dataProvider->fetchAll($dataProvider->getEmptyConfig()->setFilter($childCondition->getFilter($model)));
            if ($itemCollection) {
                $collection = $this->setSubItemsToCollection(
                    $clipboardItem,
                    $this->getSubClipboardItems($clipboardItems, $itemCollection),
                    $collection,
                    $environment
                );
            }
        }

        return $collection;
    }
protected function getHierarchyCollection(array $clipboardItems, EnvironmentInterface $environment)
    {
        $dataProvider   = $environment->getDataProvider();
        $inputProvider  = $environment->getInputProvider();
        $dataDefinition = $environment->getDataDefinition();
        $relationShip   = $dataDefinition->getModelRelationshipDefinition();
        $childCondition = $relationShip->getChildCondition($dataDefinition->getName(), $dataDefinition->getName());

        $collection = [];

        $originalPasteMode = $inputProvider->hasParameter('after') ? 'after' : 'into';

        $previousItem = null;
        foreach ($clipboardItems as $clipboardItem) {
            $modelId = $clipboardItem->getModelId();
            if (!$modelId
                || \array_key_exists($modelId->getSerialized(), $collection)
            ) {
                continue;
            }

            $pasteMode  = $previousItem ? 'after' : $originalPasteMode;
            $pasteAfter =
                $previousItem ? $previousItem->getModelId()->getSerialized() : $inputProvider->getParameter($pasteMode);

            $collection[$modelId->getSerialized()] = [
                'item'       => $clipboardItem,
                'pasteAfter' => $pasteAfter,
                'pasteMode'  => $pasteMode
            ];

            $previousItem = $clipboardItem;

            $model =
                $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));

            $itemCollection =
                $dataProvider->fetchAll($dataProvider->getEmptyConfig()->setFilter($childCondition->getFilter($model)));
            if ($itemCollection) {
                $collection = $this->setSubItemsToCollection(
                    $clipboardItem,
                    $this->getSubClipboardItems($clipboardItems, $itemCollection),
                    $collection,
                    $environment
                );
            }
        }

        return $collection;
    }
protected function getHierarchyCollection ( array $ clipboardItems , EnvironmentInterface $ environment ) { $ dataProvider = $ environment -> getDataProvider ( ) ; $ inputProvider = $ environment -> getInputProvider ( ) ; $ dataDefinition = $ environment -> getDataDefinition ( ) ; $ relationShip = $ dataDefinition -> getModelRelationshipDefinition ( ) ; $ childCondition = $ relationShip -> getChildCondition ( $ dataDefinition -> getName ( ) , $ dataDefinition -> getName ( ) ) ; $ collection = [ ] ; $ originalPasteMode = $ inputProvider -> hasParameter ( 'after' ) ? 'after' : 'into' ; $ previousItem = null ; foreach ( $ clipboardItems as $ clipboardItem ) { $ modelId = $ clipboardItem -> getModelId ( ) ; if ( ! $ modelId || \ array_key_exists ( $ modelId -> getSerialized ( ) , $ collection ) ) { continue ; } $ pasteMode = $ previousItem ? 'after' : $ originalPasteMode ; $ pasteAfter = $ previousItem ? $ previousItem -> getModelId ( ) -> getSerialized ( ) : $ inputProvider -> getParameter ( $ pasteMode ) ; $ collection [ $ modelId -> getSerialized ( ) ] = [ 'item' => $ clipboardItem , 'pasteAfter' => $ pasteAfter , 'pasteMode' => $ pasteMode ] ; $ previousItem = $ clipboardItem ; $ model = $ dataProvider -> fetch ( $ dataProvider -> getEmptyConfig ( ) -> setId ( $ modelId -> getId ( ) ) ) ; $ itemCollection = $ dataProvider -> fetchAll ( $ dataProvider -> getEmptyConfig ( ) -> setFilter ( $ childCondition -> getFilter ( $ model ) ) ) ; if ( $ itemCollection ) { $ collection = $ this -> setSubItemsToCollection ( $ clipboardItem , $ this -> getSubClipboardItems ( $ clipboardItems , $ itemCollection ) , $ collection , $ environment ) ; } } return $ collection ; }
Get hierarchy collection.

@param array                $clipboardItems The clipboard items.
@param EnvironmentInterface $environment    The environment.

@return array
Get hierarchy collection .