Bundle/PageBundle/Helper/PageHelper.php
public function renderPageByUrl($uri, $url, $locale, $layout = null)
    {
        $page = null;
        if ($viewReference = $this->viewReferenceRepository->getReferenceByUrl($url, $locale)) {
            $page = $this->findPageByReference($viewReference);
            $this->checkPageValidity($page, ['url' => $url, 'locale' => $locale]);
            $page->setReference($viewReference);

            if ($page instanceof BasePage
                && $page->getSeo()
                && $page->getSeo()->getRedirectTo()
                && $page->getSeo()->getRedirectTo()->getLinkType() != Link::TYPE_NONE
                && !$this->session->get('victoire.edit_mode', false)) {
                $link = $page->getSeo()->getRedirectTo();

                return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl($link->getParameters()));
            }

            return $this->renderPage($page, $layout);
        } else {
            try {
                /** @var Error404 $error404 */
                $error404 = $this->entityManager->getRepository('VictoireSeoBundle:Error404')->findOneBy(['url' => $uri]);
                /** @var Redirection $redirection */
                $redirection = $this->entityManager->getRepository('VictoireSeoBundle:Redirection')->findOneBy(['url' => $uri]);

                $result = $this->redirectionHandler->handleError($redirection, $error404);

                if ($result instanceof Redirection) {
                    return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl(
                        $result->getLink()->getParameters()
                    ), Response::HTTP_MOVED_PERMANENTLY);
                } elseif ($result->getRedirection()) {
                    return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl(
                        $result->getRedirection()->getLink()->getParameters()
                    ));
                }
            } catch (NoResultException $e) {
                $error = new Error404();

                $error->setUrl($uri);
                $error->setType($this->redirectionHandler->handleErrorExtension(pathinfo($uri, PATHINFO_EXTENSION)));

                $this->entityManager->persist($error);
                $this->entityManager->flush();
            }

            throw new NotFoundHttpException(sprintf('Page not found (url: "%s", locale: "%s")', $url, $locale));
        }
    }
public function renderPageByUrl($uri, $url, $locale, $layout = null)
    {
        $page = null;
        if ($viewReference = $this->viewReferenceRepository->getReferenceByUrl($url, $locale)) {
            $page = $this->findPageByReference($viewReference);
            $this->checkPageValidity($page, ['url' => $url, 'locale' => $locale]);
            $page->setReference($viewReference);

            if ($page instanceof BasePage
                && $page->getSeo()
                && $page->getSeo()->getRedirectTo()
                && $page->getSeo()->getRedirectTo()->getLinkType() != Link::TYPE_NONE
                && !$this->session->get('victoire.edit_mode', false)) {
                $link = $page->getSeo()->getRedirectTo();

                return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl($link->getParameters()));
            }

            return $this->renderPage($page, $layout);
        } else {
            try {
                /** @var Error404 $error404 */
                $error404 = $this->entityManager->getRepository('VictoireSeoBundle:Error404')->findOneBy(['url' => $uri]);
                /** @var Redirection $redirection */
                $redirection = $this->entityManager->getRepository('VictoireSeoBundle:Redirection')->findOneBy(['url' => $uri]);

                $result = $this->redirectionHandler->handleError($redirection, $error404);

                if ($result instanceof Redirection) {
                    return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl(
                        $result->getLink()->getParameters()
                    ), Response::HTTP_MOVED_PERMANENTLY);
                } elseif ($result->getRedirection()) {
                    return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl(
                        $result->getRedirection()->getLink()->getParameters()
                    ));
                }
            } catch (NoResultException $e) {
                $error = new Error404();

                $error->setUrl($uri);
                $error->setType($this->redirectionHandler->handleErrorExtension(pathinfo($uri, PATHINFO_EXTENSION)));

                $this->entityManager->persist($error);
                $this->entityManager->flush();
            }

            throw new NotFoundHttpException(sprintf('Page not found (url: "%s", locale: "%s")', $url, $locale));
        }
    }
public function renderPageByUrl ( $ uri , $ url , $ locale , $ layout = null ) { $ page = null ; if ( $ viewReference = $ this -> viewReferenceRepository -> getReferenceByUrl ( $ url , $ locale ) ) { $ page = $ this -> findPageByReference ( $ viewReference ) ; $ this -> checkPageValidity ( $ page , [ 'url' => $ url , 'locale' => $ locale ] ) ; $ page -> setReference ( $ viewReference ) ; if ( $ page instanceof BasePage && $ page -> getSeo ( ) && $ page -> getSeo ( ) -> getRedirectTo ( ) && $ page -> getSeo ( ) -> getRedirectTo ( ) -> getLinkType ( ) != Link :: TYPE_NONE && ! $ this -> session -> get ( 'victoire.edit_mode' , false ) ) { $ link = $ page -> getSeo ( ) -> getRedirectTo ( ) ; return new RedirectResponse ( $ this -> container -> get ( 'victoire_widget.twig.link_extension' ) -> victoireLinkUrl ( $ link -> getParameters ( ) ) ) ; } return $ this -> renderPage ( $ page , $ layout ) ; } else { try { /** @var Error404 $error404 */ $ error404 = $ this -> entityManager -> getRepository ( 'VictoireSeoBundle:Error404' ) -> findOneBy ( [ 'url' => $ uri ] ) ; /** @var Redirection $redirection */ $ redirection = $ this -> entityManager -> getRepository ( 'VictoireSeoBundle:Redirection' ) -> findOneBy ( [ 'url' => $ uri ] ) ; $ result = $ this -> redirectionHandler -> handleError ( $ redirection , $ error404 ) ; if ( $ result instanceof Redirection ) { return new RedirectResponse ( $ this -> container -> get ( 'victoire_widget.twig.link_extension' ) -> victoireLinkUrl ( $ result -> getLink ( ) -> getParameters ( ) ) , Response :: HTTP_MOVED_PERMANENTLY ) ; } elseif ( $ result -> getRedirection ( ) ) { return new RedirectResponse ( $ this -> container -> get ( 'victoire_widget.twig.link_extension' ) -> victoireLinkUrl ( $ result -> getRedirection ( ) -> getLink ( ) -> getParameters ( ) ) ) ; } } catch ( NoResultException $ e ) { $ error = new Error404 ( ) ; $ error -> setUrl ( $ uri ) ; $ error -> setType ( $ this -> redirectionHandler -> handleErrorExtension ( pathinfo ( $ uri , PATHINFO_EXTENSION ) ) ) ; $ this -> entityManager -> persist ( $ error ) ; $ this -> entityManager -> flush ( ) ; } throw new NotFoundHttpException ( sprintf ( 'Page not found (url: "%s", locale: "%s")' , $ url , $ locale ) ) ; } }
Generates a response from a page url.
If seo redirect, return target.

@param string      $uri
@param string      $url
@param             $locale
@param string|null $layout

@return Response
Generates a response from a page url . If seo redirect return target .