vendor\project-biz\portal-bundle\src\Controller\PagesController.php line 13

Open in your IDE?
  1. <?php
  2. namespace ProjectBiz\PortalBundle\Controller;
  3. use ProjectBiz\DatabaseBundle\Database\Criteria\CriteriaComparison;
  4. use ProjectBiz\DatabaseBundle\Database\Criteria\CriteriaComposite;
  5. use ProjectBiz\DatabaseBundle\Database\Criteria\CriteriaConstant;
  6. use ProjectBiz\DatabaseBundle\Database\Criteria\CriteriaMappedColumn;
  7. use Symfony\Component\HttpFoundation\Request;
  8. class PagesController extends BaseController
  9. {
  10.     public function index(Request $request$slug
  11.     {
  12.         $pageRepo $this->getGenericRepository('Pages');
  13.         $criteria = new CriteriaComposite(
  14.             'AND',
  15.             [
  16.                 new CriteriaComparison('=', new CriteriaMappedColumn('Pages_Slug'), new CriteriaConstant($slug)),
  17.                 new CriteriaComparison('=', new CriteriaMappedColumn('Pages_Active'), new CriteriaConstant(1))
  18.             ]
  19.         );
  20.         $page $pageRepo->findOneBy($criteria);
  21.         
  22.         if ($page) {
  23.             if (!$this->getSecurityContextWrapper()->checkRights($page['Pages_PermissionRead'])) {
  24.                 throw $this->createAccessDeniedException();
  25.             }
  26.             $params = [
  27.                 'content'   => $page['Pages_Content'],
  28.                 'title'     => $page['Pages_Title'],
  29.                 'breadcrumbs'       => [
  30.                     [
  31.                         'label' => $this->container->getParameter('citibiz.portal'),
  32.                         'href'  => $this->generateUrl('portal')
  33.                     ],
  34.                     [
  35.                         'label' => $page['Pages_Title'],
  36.                         'href'  => $this->generateUrl('pages', ['slug' => $page['Pages_Slug']])
  37.                     ]
  38.                 ]
  39.             ];
  40.             if (!empty($page['Pages_Template'])) {
  41.                 return $this->render($page['Pages_Template'], $params);
  42.             }
  43.             return $this->render('@ProjectBizPortal/Pages/index.html.twig'$params);
  44.         }
  45.         throw $this->createNotFoundException();
  46.     }
  47. }