src/Contao/View/Contao2BackendView/ActionHandler/ShowHandler.php
protected function getModel(EnvironmentInterface $environment)
    {
        $modelId      = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id'));
        $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
        $model        = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));

        if ($model) {
            return $model;
        }

        $eventDispatcher = $environment->getEventDispatcher();

        $eventDispatcher->dispatch(
            ContaoEvents::SYSTEM_LOG,
            new LogEvent(
                \sprintf(
                    'Could not find ID %s in %s. DC_General show()',
                    $modelId->getId(),
                    $environment->getDataDefinition()->getName()
                ),
                __CLASS__ . '::' . __FUNCTION__,
                TL_ERROR
            )
        );

        $eventDispatcher->dispatch(
            ContaoEvents::CONTROLLER_REDIRECT,
            new RedirectEvent('contao?act=error')
        );

        return null;
    }
protected function getModel(EnvironmentInterface $environment)
    {
        $modelId      = ModelId::fromSerialized($environment->getInputProvider()->getParameter('id'));
        $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
        $model        = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));

        if ($model) {
            return $model;
        }

        $eventDispatcher = $environment->getEventDispatcher();

        $eventDispatcher->dispatch(
            ContaoEvents::SYSTEM_LOG,
            new LogEvent(
                \sprintf(
                    'Could not find ID %s in %s. DC_General show()',
                    $modelId->getId(),
                    $environment->getDataDefinition()->getName()
                ),
                __CLASS__ . '::' . __FUNCTION__,
                TL_ERROR
            )
        );

        $eventDispatcher->dispatch(
            ContaoEvents::CONTROLLER_REDIRECT,
            new RedirectEvent('contao?act=error')
        );

        return null;
    }
protected function getModel ( EnvironmentInterface $ environment ) { $ modelId = ModelId :: fromSerialized ( $ environment -> getInputProvider ( ) -> getParameter ( 'id' ) ) ; $ dataProvider = $ environment -> getDataProvider ( $ modelId -> getDataProviderName ( ) ) ; $ model = $ dataProvider -> fetch ( $ dataProvider -> getEmptyConfig ( ) -> setId ( $ modelId -> getId ( ) ) ) ; if ( $ model ) { return $ model ; } $ eventDispatcher = $ environment -> getEventDispatcher ( ) ; $ eventDispatcher -> dispatch ( ContaoEvents :: SYSTEM_LOG , new LogEvent ( \ sprintf ( 'Could not find ID %s in %s. DC_General show()' , $ modelId -> getId ( ) , $ environment -> getDataDefinition ( ) -> getName ( ) ) , __CLASS__ . '::' . __FUNCTION__ , TL_ERROR ) ) ; $ eventDispatcher -> dispatch ( ContaoEvents :: CONTROLLER_REDIRECT , new RedirectEvent ( 'contao?act=error' ) ) ; return null ; }
Retrieve the model from the database or redirect to error page if model could not be found.

@param EnvironmentInterface $environment The environment.

@return ModelInterface|null
Retrieve the model from the database or redirect to error page if model could not be found .