src/Controller/DefaultController.php
private function applyAction(array &$action, array &$deepCopyList, ModelInterface $parentModel = null)
    {
        /** @var ModelInterface|null $model */
        $model = $action['model'];
        /** @var ItemInterface $item */
        $item = $action['item'];

        if ($item->isCreate()) {
            // create new model
            $model = $this->createEmptyModelWithDefaults();
        } elseif ($item->isCopy() || $isDeepCopy = $item->isDeepCopy()) {
            // copy model
            $model       = $this->modelCollector->getModel(ModelId::fromModel($model));
            $clonedModel = $this->doCloneAction($model);

            if (isset($isDeepCopy) && $isDeepCopy) {
                $deepCopyList[] = [
                    'origin' => $model,
                    'model'  => $clonedModel,
                ];
            }

            $model = $clonedModel;
        }

        if (!$model) {
            throw new \UnexpectedValueException(
                'Invalid clipboard action entry, no model created. ' . $item->getAction()
            );
        }

        if ($parentModel) {
            $this->relationshipManager->setParent($model, $parentModel);
        }

        $action['model'] = $model;
    }
private function applyAction(array &$action, array &$deepCopyList, ModelInterface $parentModel = null)
    {
        /** @var ModelInterface|null $model */
        $model = $action['model'];
        /** @var ItemInterface $item */
        $item = $action['item'];

        if ($item->isCreate()) {
            // create new model
            $model = $this->createEmptyModelWithDefaults();
        } elseif ($item->isCopy() || $isDeepCopy = $item->isDeepCopy()) {
            // copy model
            $model       = $this->modelCollector->getModel(ModelId::fromModel($model));
            $clonedModel = $this->doCloneAction($model);

            if (isset($isDeepCopy) && $isDeepCopy) {
                $deepCopyList[] = [
                    'origin' => $model,
                    'model'  => $clonedModel,
                ];
            }

            $model = $clonedModel;
        }

        if (!$model) {
            throw new \UnexpectedValueException(
                'Invalid clipboard action entry, no model created. ' . $item->getAction()
            );
        }

        if ($parentModel) {
            $this->relationshipManager->setParent($model, $parentModel);
        }

        $action['model'] = $model;
    }
private function applyAction ( array & $ action , array & $ deepCopyList , ModelInterface $ parentModel = null ) { /** @var ModelInterface|null $model */ $ model = $ action [ 'model' ] ; /** @var ItemInterface $item */ $ item = $ action [ 'item' ] ; if ( $ item -> isCreate ( ) ) { // create new model $ model = $ this -> createEmptyModelWithDefaults ( ) ; } elseif ( $ item -> isCopy ( ) || $ isDeepCopy = $ item -> isDeepCopy ( ) ) { // copy model $ model = $ this -> modelCollector -> getModel ( ModelId :: fromModel ( $ model ) ) ; $ clonedModel = $ this -> doCloneAction ( $ model ) ; if ( isset ( $ isDeepCopy ) && $ isDeepCopy ) { $ deepCopyList [ ] = [ 'origin' => $ model , 'model' => $ clonedModel , ] ; } $ model = $ clonedModel ; } if ( ! $ model ) { throw new \ UnexpectedValueException ( 'Invalid clipboard action entry, no model created. ' . $ item -> getAction ( ) ) ; } if ( $ parentModel ) { $ this -> relationshipManager -> setParent ( $ model , $ parentModel ) ; } $ action [ 'model' ] = $ model ; }
Apply the action onto the model.

This will create or clone the model in the action.

@param array          $action       The action, containing a model and an item.
@param array          $deepCopyList A list of models that need deep copy.
@param ModelInterface $parentModel  The parent model.

@return void

@throws \UnexpectedValueException When the action is neither create, copy or deep copy.
Apply the action onto the model .