src/Controller/Pages/CinemaController.php line 44

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Pages;
  3. use App\Controller\Objects\HomeFacebookItem;
  4. use App\Kernel;
  5. use App\Controller\AbstractKasController;
  6. use App\Controller\AbstractKasModel;
  7. use App\Controller\Database;
  8. use App\Controller\PageInfo;
  9. use Symfony\Bundle\FrameworkBundle\Console\Application;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\Cache\Adapter\MemcachedAdapter;
  12. use Symfony\Component\Console\Input\ArrayInput;
  13. use Symfony\Component\Console\Output\BufferedOutput;
  14. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  15. use Symfony\Component\HttpFoundation\RequestStack;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\VarDumper;
  19. use Doctrine\DBAL\ParameterType;
  20. class CinemaController extends AbstractKasController
  21. {
  22.     public function __construct(RequestStack $requestStackDatabase $dbPageInfo $pageInfo)
  23.     {
  24.         parent::__construct($requestStack$db$pageInfo);
  25.         $this->request $requestStack->getCurrentRequest();
  26.         $this->object_model = new ObjectModel($db);
  27.         $this->home_model = new HomeModel($db);
  28.         $this->model = new CinemaModel($db);
  29.         $this->requestStack $requestStack;
  30.         $this->db           $db;
  31.         $this->pageInfo     $pageInfo;
  32.     }
  33.     /**
  34.      * @Route("/kino-svet/fotogalerie")
  35.      * @Route("/letni-kino/fotogalerie")
  36.      * @return Response
  37.      * @throws \Facebook\Exceptions\FacebookSDKException
  38.      */
  39.     public function fotogalerie(): Response
  40.     {
  41.         $link $this->request->getRequestUri();
  42.         $link str_replace('/fotogalerie'''$link);
  43.         $model = new ObjectModel($this->db);
  44.         $objectinfo $model->getObjectInfo($link);
  45.         //pokud nenalezeno, tak 404
  46.         if (!$objectinfo->isFound()) return $this->render('/pages/404.html.twig', [
  47.             'pageinfo' => $this->pageInfo
  48.         ]);
  49.         $model = new HomeModel($this->db);
  50.         $top_events $model->getTopEvents(); //dump($top_events);
  51.         $facebook_feed $model->getFacebookFeed();
  52.         return $this->render('/pages/gallery.html.twig', [
  53.             'pageinfo' => $this->pageInfo,
  54.             'objectinfo' => $objectinfo,
  55.             'top_events' => $top_events,
  56.             'facebook_feed' => $facebook_feed
  57.         ]);
  58.     }
  59.     /**
  60.      * @Route("/kino/zverejneni-akce")
  61.      * @Route("/kino-svet/zverejneni-akce")
  62.      * @Route("/letni-kino/zverejneni-akce")
  63.      * @return Response
  64.      * @throws \Facebook\Exceptions\FacebookSDKException
  65.      */
  66.     public function publish_form(): Response
  67.     {
  68.         $l $this->request->getRequestUri();
  69.         $arr explode('/'$l);
  70.         $l $arr[1];
  71.         if ($l=='kino'$l 'kino-svet';
  72.         $object $l;
  73.         $model = new ObjectModel($this->db);
  74.         $objectinfo $model->getObjectInfo('/'.$object);
  75.         $objectinfo->setSubtitle($objectinfo->getTitle());
  76.         $objectinfo->setTitle('Zveřejnění akce');
  77.         $objectinfo->setButtons([]);
  78.         //pokud nenalezeno, tak 404
  79.         if (!$objectinfo->isFound()) return $this->render('/pages/404.html.twig', [
  80.             'pageinfo' => $this->pageInfo
  81.         ]);
  82.         $top_events $this->home_model->getTopEvents();
  83.         $facebook_feed $this->home_model->getFacebookFeed();
  84.         return $this->render('/pages/publish_form.html.twig', [
  85.             'pageinfo' => $this->pageInfo,
  86.             'objectinfo' => $objectinfo,
  87.             'top_events' => $top_events,
  88.             'facebook_feed' => $facebook_feed,
  89.             'g_site_key' => getenv('G_SITE_KEY')
  90.         ]);
  91.     }
  92.     /**
  93.      * @Route("/kino/{link}")
  94.      * @Route("/kino-svet/{link}")
  95.      * @Route("/letni-kino/{link}")
  96.      * @return Response
  97.      * @throws \Facebook\Exceptions\FacebookSDKException
  98.      */
  99.     public function event($link): Response
  100.     {
  101.         $l $this->request->getRequestUri();
  102.         $arr explode('/'$l);
  103.         $l $arr[1];
  104.         if ($l=='kino'$l 'kino-svet';
  105.         // /kino/359134-zachrante-tygra
  106.         $objectinfo $this->object_model->getObjectInfo('/'.$l);
  107.         $event $this->model->getCinemaEvent($link);
  108.         //pokud nenalezeno, tak 404
  109.         if (!$objectinfo->isFound() || $event->getName()=='') return $this->render('/pages/404.html.twig', [
  110.             'pageinfo' => $this->pageInfo
  111.         ]);
  112.         $top_events $this->home_model->getTopEvents();
  113.         $facebook_feed $this->home_model->getFacebookFeed();
  114.         return $this->render('/pages/cinema_event.html.twig', [
  115.             'event' => $event,
  116.             'pageinfo' => $this->pageInfo,
  117.             'objectinfo' => $objectinfo,
  118.             'top_events' => $top_events,
  119.             'facebook_feed' => $facebook_feed
  120.         ]);
  121.     }
  122. }
  123. ?>