src/Controller/CmsController.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Main\Pages;
  4. use App\Entity\Main\Users;
  5. use App\Service\ApiService;
  6. use App\Service\AuthService;
  7. use App\Entity\Main\Attorneys;
  8. use App\Entity\Main\CronQueue;
  9. use App\Entity\Main\RequestTerms;
  10. use App\Entity\Main\Applications;
  11. use App\Service\ApplicationService;
  12. use App\Entity\Main\IncomingDocuments;
  13. use App\Entity\ExtendObject\ExtendObject;
  14. use Doctrine\Common\Collections\Criteria;
  15. use Knp\Component\Pager\PaginatorInterface;
  16. use Symfony\Component\HttpFoundation\Request;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. use Symfony\Component\HttpFoundation\JsonResponse;
  20. use Symfony\Contracts\Translation\TranslatorInterface;
  21. use Symfony\Component\HttpFoundation\File\UploadedFile;
  22. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  23. use Symfony\Component\HttpFoundation\File\Exception\FileException;
  24. class CmsController extends AbstractController
  25. {
  26.     /**
  27.      * @Route("/{slug}", name="cms")
  28.      */
  29.     public function cms($slug)
  30.     {
  31.         //Ищем страницу
  32.         $page $this->getDoctrine()->getRepository('App\Entity\Main\Pages')->findOneBy(['slug' => $slug]);
  33.         
  34.         //Если страница не найдена, 404 ошибка
  35.         if(!$page instanceof Pages){
  36.             throw $this->createNotFoundException('Page does not exist');
  37.         }
  38.         
  39.         //Если это главная страница - редиректим
  40.         if($page->getType() == 1){
  41.             return $this->redirectToRoute('home', [], 302);
  42.         }
  43.         
  44.         //Настройки для футеру
  45.         $setting $this->getDoctrine()->getRepository('App\Entity\Main\Setting')->find(1);
  46.         
  47.         return $this->render('page/cms.html.twig', ['page' => $page'setting' => $setting]);
  48.     }
  49. }