<?php
namespace App\Controller;
use App\Entity\Main\Pages;
use App\Entity\Main\Users;
use App\Service\ApiService;
use App\Service\AuthService;
use App\Entity\Main\Attorneys;
use App\Entity\Main\CronQueue;
use App\Entity\Main\RequestTerms;
use App\Entity\Main\Applications;
use App\Service\ApplicationService;
use App\Entity\Main\IncomingDocuments;
use App\Entity\ExtendObject\ExtendObject;
use Doctrine\Common\Collections\Criteria;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
class CmsController extends AbstractController
{
/**
* @Route("/{slug}", name="cms")
*/
public function cms($slug)
{
//Ищем страницу
$page = $this->getDoctrine()->getRepository('App\Entity\Main\Pages')->findOneBy(['slug' => $slug]);
//Если страница не найдена, 404 ошибка
if(!$page instanceof Pages){
throw $this->createNotFoundException('Page does not exist');
}
//Если это главная страница - редиректим
if($page->getType() == 1){
return $this->redirectToRoute('home', [], 302);
}
//Настройки для футеру
$setting = $this->getDoctrine()->getRepository('App\Entity\Main\Setting')->find(1);
return $this->render('page/cms.html.twig', ['page' => $page, 'setting' => $setting]);
}
}