bundle/EventListener/NoViewTemplateEventListener.php
public function getController(FilterControllerEvent $event): void
    {
        if (!$this->enabled || $event->getRequestType() !== Kernel::MASTER_REQUEST) {
            return;
        }

        $request = $event->getRequest();

        $view = $request->attributes->get('view');
        if (!$view instanceof View || $view->getViewType() !== 'full') {
            return;
        }

        if (is_string($view->getTemplateIdentifier())) {
            return;
        }

        $event->setController(
            function (): RedirectResponse {
                $rootLocationId = $this->configResolver->getParameter('content.tree_root.location_id');

                return new RedirectResponse(
                    $this->urlGenerator->generate('ez_urlalias', ['locationId' => $rootLocationId]),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        );
    }
public function getController(FilterControllerEvent $event): void
    {
        if (!$this->enabled || $event->getRequestType() !== Kernel::MASTER_REQUEST) {
            return;
        }

        $request = $event->getRequest();

        $view = $request->attributes->get('view');
        if (!$view instanceof View || $view->getViewType() !== 'full') {
            return;
        }

        if (is_string($view->getTemplateIdentifier())) {
            return;
        }

        $event->setController(
            function (): RedirectResponse {
                $rootLocationId = $this->configResolver->getParameter('content.tree_root.location_id');

                return new RedirectResponse(
                    $this->urlGenerator->generate('ez_urlalias', ['locationId' => $rootLocationId]),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        );
    }
public function getController ( FilterControllerEvent $ event ) : void { if ( ! $ this -> enabled || $ event -> getRequestType ( ) !== Kernel :: MASTER_REQUEST ) { return ; } $ request = $ event -> getRequest ( ) ; $ view = $ request -> attributes -> get ( 'view' ) ; if ( ! $ view instanceof View || $ view -> getViewType ( ) !== 'full' ) { return ; } if ( is_string ( $ view -> getTemplateIdentifier ( ) ) ) { return ; } $ event -> setController ( function ( ) : RedirectResponse { $ rootLocationId = $ this -> configResolver -> getParameter ( 'content.tree_root.location_id' ) ; return new RedirectResponse ( $ this -> urlGenerator -> generate ( 'ez_urlalias' , [ 'locationId' => $ rootLocationId ] ) , RedirectResponse :: HTTP_MOVED_PERMANENTLY ) ; } ) ; }
Redirects to the frontpage for any full view that does not have a template configured.
Redirects to the frontpage for any full view that does not have a template configured .