src/Contao/View/Contao2BackendView/ActionHandler/DeleteHandler.php
protected function guardIsDeletable(EnvironmentInterface $environment, ModelIdInterface $modelId, $redirect = false)
    {
        $dataDefinition = $environment->getDataDefinition();
        if ($dataDefinition->getBasicDefinition()->isDeletable()) {
            return;
        }

        if (false === $redirect) {
            throw new NotDeletableException($modelId->getDataProviderName());
        }

        $eventDispatcher = $environment->getEventDispatcher();

        $eventDispatcher->dispatch(
            ContaoEvents::SYSTEM_LOG,
            new LogEvent(
                \sprintf(
                    'Table "%s" is not deletable DC_General - DefaultController - delete()',
                    $dataDefinition->getName()
                ),
                __CLASS__ . '::delete()',
                TL_ERROR
            )
        );

        $eventDispatcher->dispatch(
            ContaoEvents::CONTROLLER_REDIRECT,
            new RedirectEvent('contao?act=error')
        );
    }
protected function guardIsDeletable(EnvironmentInterface $environment, ModelIdInterface $modelId, $redirect = false)
    {
        $dataDefinition = $environment->getDataDefinition();
        if ($dataDefinition->getBasicDefinition()->isDeletable()) {
            return;
        }

        if (false === $redirect) {
            throw new NotDeletableException($modelId->getDataProviderName());
        }

        $eventDispatcher = $environment->getEventDispatcher();

        $eventDispatcher->dispatch(
            ContaoEvents::SYSTEM_LOG,
            new LogEvent(
                \sprintf(
                    'Table "%s" is not deletable DC_General - DefaultController - delete()',
                    $dataDefinition->getName()
                ),
                __CLASS__ . '::delete()',
                TL_ERROR
            )
        );

        $eventDispatcher->dispatch(
            ContaoEvents::CONTROLLER_REDIRECT,
            new RedirectEvent('contao?act=error')
        );
    }
protected function guardIsDeletable ( EnvironmentInterface $ environment , ModelIdInterface $ modelId , $ redirect = false ) { $ dataDefinition = $ environment -> getDataDefinition ( ) ; if ( $ dataDefinition -> getBasicDefinition ( ) -> isDeletable ( ) ) { return ; } if ( false === $ redirect ) { throw new NotDeletableException ( $ modelId -> getDataProviderName ( ) ) ; } $ eventDispatcher = $ environment -> getEventDispatcher ( ) ; $ eventDispatcher -> dispatch ( ContaoEvents :: SYSTEM_LOG , new LogEvent ( \ sprintf ( 'Table "%s" is not deletable DC_General - DefaultController - delete()' , $ dataDefinition -> getName ( ) ) , __CLASS__ . '::delete()' , TL_ERROR ) ) ; $ eventDispatcher -> dispatch ( ContaoEvents :: CONTROLLER_REDIRECT , new RedirectEvent ( 'contao?act=error' ) ) ; }
Check if is it allowed to delete a record.

@param EnvironmentInterface $environment The environment.
@param ModelIdInterface     $modelId     The model id.
@param bool                 $redirect    If true it redirects to error page instead of throwing an exception.

@return void

@throws NotDeletableException If table can´t delete.
Check if is it allowed to delete a record .