src/Kiwi/FrontPageBundle/Controller/DefaultController.php line 53

Open in your IDE?
  1. <?php
  2. namespace Kiwi\FrontPageBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  7. class DefaultController extends Controller
  8. {
  9.     public function blankHpAction(Request $request){
  10.         $this->prerouter($request,true);
  11.     }
  12.     public function pageAction(Request $request$lang$page_uri false)
  13.     {
  14.         $uri_explode array_filter(explode('/',$page_uri));
  15.         $pageObj $this->get('page_frontend_handle');
  16.         
  17.         
  18.         $web $this->get('web_handle')->getWebByDomain($request->getHttpHost());
  19.         if(!$web)
  20.             throw new NotFoundHttpException('Doména '.$request->getHttpHost().' nenalezena nebo zrušena');
  21.         //fill config variables by parsed url
  22.         $config = array();
  23.         foreach($uri_explode as $uxv_k => $uxv) {
  24.             $config['p'.($uxv_k+1)] = $uxv;
  25.         }
  26.         //look for fidt match page
  27.         $page_by_uid false;
  28.         foreach(array_reverse($uri_explode) as $uri_part) {
  29.             if(!$page_by_uid)
  30.                 $page_by_uid $this->get('page_handle')->getPageBySeoName($uri_part$web->getId());
  31.         }
  32.         if(!$page_by_uid)
  33.             throw new NotFoundHttpException("Stránka nebyla nalezena");
  34.         $pageObj->setPageByReference($lang,$page_by_uid);
  35.         $pageObj->setRequest($request);
  36.         $redir_url $pageObj->getPageRedirectUrl();
  37.         if($redir_url) {
  38.             $suffix $pageObj->getRedirectSuffix();
  39.             return $this->redirect($redir_url.$suffix);
  40.         } else {
  41.             return $pageObj->getPageHtml();
  42.         }
  43.     }
  44.     private function prerouter(Request $request) {
  45.         //$path = $request->getPathInfo();
  46.         $this->get('routing_handle')->getRedirect($request);
  47.     }
  48. }