src/Contao/View/Contao2BackendView/Controller/ClipboardController.php
private function addToClipboard(ActionEvent $event)
    {
        $actionName  = $event->getAction()->getName();
        $environment = $event->getEnvironment();
        $input       = $environment->getInputProvider();
        $clipboard   = $environment->getClipboard();

        $parentIdRaw = $input->getParameter('pid');
        if ($parentIdRaw) {
            $parentId = ModelId::fromSerialized($parentIdRaw);
        } else {
            $parentId = null;
        }

        if (!($clipboardActionName = $this->translateActionName($actionName))) {
            return;
        }

        if ('create' === $actionName) {
            if ($this->isAddingAllowed($environment)) {
                return;
            }

            $providerName = $environment->getDataDefinition()->getBasicDefinition()->getDataProvider();
            $item         = new UnsavedItem($clipboardActionName, $parentId, $providerName);

            // Remove other create items, there can only be one create item in the clipboard or many others
            $clipboard->clear();
        } else {
            $modelIdRaw = $input->getParameter('source');
            $modelId    = ModelId::fromSerialized($modelIdRaw);

            // If edit several don´t remove items from the clipboard.
            $this->removeItemsFromClipboard($event);

            // Only push item to clipboard if manual sorting is used.
            if (Item::COPY === $clipboardActionName && !ViewHelpers::getManualSortingProperty($environment)) {
                return;
            }

            // create the new item
            $item = new Item($clipboardActionName, $parentId, $modelId);
        }

        // If edit several don´t redirect do home and push item to the clipboard.
        if ('select' === $input->getParameter('act')) {
            $clipboard->push($item)->saveTo($environment);

            return;
        }

        // Let the clipboard save it's values persistent.
        $clipboard->clear()->push($item)->saveTo($environment);

        ViewHelpers::redirectHome($environment);
    }
private function addToClipboard(ActionEvent $event)
    {
        $actionName  = $event->getAction()->getName();
        $environment = $event->getEnvironment();
        $input       = $environment->getInputProvider();
        $clipboard   = $environment->getClipboard();

        $parentIdRaw = $input->getParameter('pid');
        if ($parentIdRaw) {
            $parentId = ModelId::fromSerialized($parentIdRaw);
        } else {
            $parentId = null;
        }

        if (!($clipboardActionName = $this->translateActionName($actionName))) {
            return;
        }

        if ('create' === $actionName) {
            if ($this->isAddingAllowed($environment)) {
                return;
            }

            $providerName = $environment->getDataDefinition()->getBasicDefinition()->getDataProvider();
            $item         = new UnsavedItem($clipboardActionName, $parentId, $providerName);

            // Remove other create items, there can only be one create item in the clipboard or many others
            $clipboard->clear();
        } else {
            $modelIdRaw = $input->getParameter('source');
            $modelId    = ModelId::fromSerialized($modelIdRaw);

            // If edit several don´t remove items from the clipboard.
            $this->removeItemsFromClipboard($event);

            // Only push item to clipboard if manual sorting is used.
            if (Item::COPY === $clipboardActionName && !ViewHelpers::getManualSortingProperty($environment)) {
                return;
            }

            // create the new item
            $item = new Item($clipboardActionName, $parentId, $modelId);
        }

        // If edit several don´t redirect do home and push item to the clipboard.
        if ('select' === $input->getParameter('act')) {
            $clipboard->push($item)->saveTo($environment);

            return;
        }

        // Let the clipboard save it's values persistent.
        $clipboard->clear()->push($item)->saveTo($environment);

        ViewHelpers::redirectHome($environment);
    }
private function addToClipboard ( ActionEvent $ event ) { $ actionName = $ event -> getAction ( ) -> getName ( ) ; $ environment = $ event -> getEnvironment ( ) ; $ input = $ environment -> getInputProvider ( ) ; $ clipboard = $ environment -> getClipboard ( ) ; $ parentIdRaw = $ input -> getParameter ( 'pid' ) ; if ( $ parentIdRaw ) { $ parentId = ModelId :: fromSerialized ( $ parentIdRaw ) ; } else { $ parentId = null ; } if ( ! ( $ clipboardActionName = $ this -> translateActionName ( $ actionName ) ) ) { return ; } if ( 'create' === $ actionName ) { if ( $ this -> isAddingAllowed ( $ environment ) ) { return ; } $ providerName = $ environment -> getDataDefinition ( ) -> getBasicDefinition ( ) -> getDataProvider ( ) ; $ item = new UnsavedItem ( $ clipboardActionName , $ parentId , $ providerName ) ; // Remove other create items, there can only be one create item in the clipboard or many others $ clipboard -> clear ( ) ; } else { $ modelIdRaw = $ input -> getParameter ( 'source' ) ; $ modelId = ModelId :: fromSerialized ( $ modelIdRaw ) ; // If edit several don´t remove items from the clipboard. $ this -> removeItemsFromClipboard ( $ event ) ; // Only push item to clipboard if manual sorting is used. if ( Item :: COPY === $ clipboardActionName && ! ViewHelpers :: getManualSortingProperty ( $ environment ) ) { return ; } // create the new item $ item = new Item ( $ clipboardActionName , $ parentId , $ modelId ) ; } // If edit several don´t redirect do home and push item to the clipboard. if ( 'select' === $ input -> getParameter ( 'act' ) ) { $ clipboard -> push ( $ item ) -> saveTo ( $ environment ) ; return ; } // Let the clipboard save it's values persistent. $ clipboard -> clear ( ) -> push ( $ item ) -> saveTo ( $ environment ) ; ViewHelpers :: redirectHome ( $ environment ) ; }
Handle "old" add to clipboard actions.

@param ActionEvent $event The action event.

@return void
Handle old add to clipboard actions .