src/View/ActionHandler/AbstractPropertyOverrideEditAllHandler.php
protected function revertValuesByErrors(
        Action $action,
        CollectionInterface $collection,
        EnvironmentInterface $environment
    ) {
        $editInformation = $GLOBALS['container']['dc-general.edit-information'];
        if (!$editInformation->hasAnyModelError()) {
            return;
        }

        $dataProvider = $environment->getDataProvider();
        $properties   = $this->getPropertiesFromSession($action, $environment);

        while ($collection->count() > 0) {
            $model = $collection->shift();

            $modelErrors = $editInformation->getModelError($model);
            if (!$modelErrors && ('edit' === $this->getMode($action))) {
                continue;
            }

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

            $originalModel = clone $revertModel;
            $revertModel->setId($revertModel->getId());

            foreach ($properties as $property) {
                if (('edit' === $this->getMode($action))
                    && !\in_array($property->getName(), $modelErrors)) {
                    continue;
                }

                $revertModel->setProperty($property->getName(), $model->getProperty($property->getName()));
            }

            $dataProvider->save($revertModel);

            $this->handlePostPersist($revertModel, $originalModel, $environment);
        }
    }
protected function revertValuesByErrors(
        Action $action,
        CollectionInterface $collection,
        EnvironmentInterface $environment
    ) {
        $editInformation = $GLOBALS['container']['dc-general.edit-information'];
        if (!$editInformation->hasAnyModelError()) {
            return;
        }

        $dataProvider = $environment->getDataProvider();
        $properties   = $this->getPropertiesFromSession($action, $environment);

        while ($collection->count() > 0) {
            $model = $collection->shift();

            $modelErrors = $editInformation->getModelError($model);
            if (!$modelErrors && ('edit' === $this->getMode($action))) {
                continue;
            }

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

            $originalModel = clone $revertModel;
            $revertModel->setId($revertModel->getId());

            foreach ($properties as $property) {
                if (('edit' === $this->getMode($action))
                    && !\in_array($property->getName(), $modelErrors)) {
                    continue;
                }

                $revertModel->setProperty($property->getName(), $model->getProperty($property->getName()));
            }

            $dataProvider->save($revertModel);

            $this->handlePostPersist($revertModel, $originalModel, $environment);
        }
    }
protected function revertValuesByErrors ( Action $ action , CollectionInterface $ collection , EnvironmentInterface $ environment ) { $ editInformation = $ GLOBALS [ 'container' ] [ 'dc-general.edit-information' ] ; if ( ! $ editInformation -> hasAnyModelError ( ) ) { return ; } $ dataProvider = $ environment -> getDataProvider ( ) ; $ properties = $ this -> getPropertiesFromSession ( $ action , $ environment ) ; while ( $ collection -> count ( ) > 0 ) { $ model = $ collection -> shift ( ) ; $ modelErrors = $ editInformation -> getModelError ( $ model ) ; if ( ! $ modelErrors && ( 'edit' === $ this -> getMode ( $ action ) ) ) { continue ; } $ revertModel = $ dataProvider -> fetch ( $ dataProvider -> getEmptyConfig ( ) -> setId ( $ model -> getId ( ) ) ) ; $ originalModel = clone $ revertModel ; $ revertModel -> setId ( $ revertModel -> getId ( ) ) ; foreach ( $ properties as $ property ) { if ( ( 'edit' === $ this -> getMode ( $ action ) ) && ! \ in_array ( $ property -> getName ( ) , $ modelErrors ) ) { continue ; } $ revertModel -> setProperty ( $ property -> getName ( ) , $ model -> getProperty ( $ property -> getName ( ) ) ) ; } $ dataProvider -> save ( $ revertModel ) ; $ this -> handlePostPersist ( $ revertModel , $ originalModel , $ environment ) ; } }
Revert model values if their have errors.

@param Action               $action      The action.
@param CollectionInterface  $collection  The collection of Models.
@param EnvironmentInterface $environment The environment.

@return void

@SuppressWarnings(PHPMD.Superglobals)
Revert model values if their have errors .