src/Controller/Frontend/DefaultController.php line 71
<?phpnamespace App\Controller\Frontend;use App\Entity\Content\News;use App\Entity\Content\StaticPage;use App\Entity\Forms\Support;use App\Entity\Geo\District;use App\Entity\Organisation\Organisation;use App\Forms\Types\Forms\SupportType;use App\Service\Olympiads\Provider;use Doctrine\ORM\EntityManagerInterface;use Knp\Component\Pager\PaginatorInterface;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;use Vich\UploaderBundle\Handler\DownloadHandler;class DefaultController extends AbstractController{/*** @var EntityManagerInterface*/private $em;public function __construct(EntityManagerInterface $em){$this->em = $em;}/*** @ Route("/", name="main")* @ Route("/main", name="real_main")**/public function index(PaginatorInterface $paginator, Provider $provider){$news_params = $this->getParameter('news');$olympiads_params = $this->getParameter('olympiads');$news = $this->em->getRepository(News::class)->findNews($news_params['main_page_news']);$events = $this->em->getRepository(News::class)->findEventsMainPage($news_params['main_page_events']);$olympCategories = $provider->findMainPage();$olympCount = $provider->findMainPageTotal();$olympTypes = $provider->findMainPageLevels();// dump($olympTypes);$orgCategories = $this->em->getRepository(\App\Entity\Organisation\University\Category::class)->findMainPage(Organisation::TYPE_VUZ);$vuzCount = $this->em->getRepository(Organisation::class)->findMainPageTotal(Organisation::TYPE_VUZ);// dump($orgCategories);$districts = $this->em->getRepository(District::class)->findMainPage();// $olympiads = $paginator->paginate($this->em->getRepository(Olympiad::class)->mainListQb(),1,$olympiads_params['main_page_count']);// dump($news);return $this->render('default/index.html.twig',['news' => $news,'events' => $events,'olympCategories' => $olympCategories,'orgCategories' => $orgCategories,'vuzCount' => $vuzCount,'districts' => $districts,'olympTypes' => $olympTypes,'olympCount' => $olympCount,]);}#[Route(path: '/file/{id}/{filename}', name: 'content_file')]#[Cache(expires: '+30 days', public: true, lastModified: 'file.getCreatedAt()', etag: "'st_image' ~ file.getId() ~ file.getCreatedAt().getTimestamp()")]public function content_file(\App\Entity\Common\File $file, $filename, DownloadHandler $downloadHandler): Response{if ($file->isPublic() === false) {throw $this->createAccessDeniedException();}// return new Response();try {$resp = $downloadHandler->downloadObject($file,'file',null,true,false);} catch (\Vich\UploaderBundle\Exception\NoFileFoundException) {throw $this->createNotFoundException();}$resp->headers->set('content-type', [$file->getData()->getMimeType()]);return $resp;}/*** @param StaticPage $page* @return \Symfony\Component\HttpFoundation\Response*/#[Route(path: '/s/{url}', name: 'static-page')]public function staticPageAction(StaticPage $page): Response{/* $page = $this->getDoctrine()->getRepository(StaticPage::class)->findOneBy(['url' => $url]);*/if ($page->isInternal()) {throw $this->createNotFoundException();//return $this->redirect('/'.$url);}return $this->render('static/static.html.twig',['page' => $page,]);}#[Route(name: 'support_page', path: '/support')]public function support(Request $request, EntityManagerInterface $em){$page = $em->getRepository(StaticPage::class)->findOneBy(['url' => 'support',]);$data = new Support();$data->setUser($this->getUser());$form = $this->createForm(SupportType::class, $data);$form->handleRequest($request);if ($form->isSubmitted() && $form->isValid()) {$em->persist($data);$em->flush();// $this->addFlash('success', 'flash.support_message_send');}return $this->render('default/support.html.twig',['page' => $page,'form_submitted' => $form->isSubmitted() && $form->isValid(),'form' => $form->createView(),]);}/*** @return \Symfony\Component\HttpFoundation\Response**/#[Route(path: 'association', name: 'association_page')]public function association(EntityManagerInterface $em){$page = $em->getRepository(StaticPage::class)->findOneBy(['url' => 'association',]);return $this->render('default/association.html.twig',['page' => $page,]);}}