src/Contao/View/Contao2BackendView/ActionHandler/DeleteHandler.php
public function delete(EnvironmentInterface $environment, ModelIdInterface $modelId)
    {
        $this->guardNotEditOnly($environment->getDataDefinition(), $modelId);
        $this->guardIsDeletable($environment, $modelId);

        $model = $this->fetchModel($environment, $modelId);

        // Trigger event before the model will be deleted.
        $preDeleteEvent = new PreDeleteModelEvent($environment, $model);
        $environment->getEventDispatcher()->dispatch($preDeleteEvent::NAME, $preDeleteEvent);

        $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
        $dataProvider->delete($model);

        // Trigger event after the model is deleted.
        $postDeleteEvent = new PostDeleteModelEvent($environment, $model);
        $environment->getEventDispatcher()->dispatch($postDeleteEvent::NAME, $postDeleteEvent);
    }
public function delete(EnvironmentInterface $environment, ModelIdInterface $modelId)
    {
        $this->guardNotEditOnly($environment->getDataDefinition(), $modelId);
        $this->guardIsDeletable($environment, $modelId);

        $model = $this->fetchModel($environment, $modelId);

        // Trigger event before the model will be deleted.
        $preDeleteEvent = new PreDeleteModelEvent($environment, $model);
        $environment->getEventDispatcher()->dispatch($preDeleteEvent::NAME, $preDeleteEvent);

        $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
        $dataProvider->delete($model);

        // Trigger event after the model is deleted.
        $postDeleteEvent = new PostDeleteModelEvent($environment, $model);
        $environment->getEventDispatcher()->dispatch($postDeleteEvent::NAME, $postDeleteEvent);
    }
public function delete ( EnvironmentInterface $ environment , ModelIdInterface $ modelId ) { $ this -> guardNotEditOnly ( $ environment -> getDataDefinition ( ) , $ modelId ) ; $ this -> guardIsDeletable ( $ environment , $ modelId ) ; $ model = $ this -> fetchModel ( $ environment , $ modelId ) ; // Trigger event before the model will be deleted. $ preDeleteEvent = new PreDeleteModelEvent ( $ environment , $ model ) ; $ environment -> getEventDispatcher ( ) -> dispatch ( $ preDeleteEvent :: NAME , $ preDeleteEvent ) ; $ dataProvider = $ environment -> getDataProvider ( $ modelId -> getDataProviderName ( ) ) ; $ dataProvider -> delete ( $ model ) ; // Trigger event after the model is deleted. $ postDeleteEvent = new PostDeleteModelEvent ( $ environment , $ model ) ; $ environment -> getEventDispatcher ( ) -> dispatch ( $ postDeleteEvent :: NAME , $ postDeleteEvent ) ; }
Delete an model.

@param EnvironmentInterface $environment Environment.
@param ModelIdInterface     $modelId     The model id.

@return void

@throws EditOnlyModeException     If the data definition is in edit only mode.
@throws NotDeletableException     If the data definition does not allow delete actions.
@throws DcGeneralRuntimeException If the model is not found.
Delete an model .