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')
        );
    }