<?php
namespace App\Controller\Pages;
use App\Controller\Objects\HomeFacebookItem;
use App\Kernel;
use App\Controller\AbstractKasController;
use App\Controller\AbstractKasModel;
use App\Controller\Database;
use App\Controller\PageInfo;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\VarDumper;
use Doctrine\DBAL\ParameterType;
class CinemaController extends AbstractKasController
{
public function __construct(RequestStack $requestStack, Database $db, PageInfo $pageInfo)
{
parent::__construct($requestStack, $db, $pageInfo);
$this->request = $requestStack->getCurrentRequest();
$this->object_model = new ObjectModel($db);
$this->home_model = new HomeModel($db);
$this->model = new CinemaModel($db);
$this->requestStack = $requestStack;
$this->db = $db;
$this->pageInfo = $pageInfo;
}
/**
* @Route("/kino-svet/fotogalerie")
* @Route("/letni-kino/fotogalerie")
* @return Response
* @throws \Facebook\Exceptions\FacebookSDKException
*/
public function fotogalerie(): Response
{
$link = $this->request->getRequestUri();
$link = str_replace('/fotogalerie', '', $link);
$model = new ObjectModel($this->db);
$objectinfo = $model->getObjectInfo($link);
//pokud nenalezeno, tak 404
if (!$objectinfo->isFound()) return $this->render('/pages/404.html.twig', [
'pageinfo' => $this->pageInfo
]);
$model = new HomeModel($this->db);
$top_events = $model->getTopEvents(); //dump($top_events);
$facebook_feed = $model->getFacebookFeed();
return $this->render('/pages/gallery.html.twig', [
'pageinfo' => $this->pageInfo,
'objectinfo' => $objectinfo,
'top_events' => $top_events,
'facebook_feed' => $facebook_feed
]);
}
/**
* @Route("/kino/zverejneni-akce")
* @Route("/kino-svet/zverejneni-akce")
* @Route("/letni-kino/zverejneni-akce")
* @return Response
* @throws \Facebook\Exceptions\FacebookSDKException
*/
public function publish_form(): Response
{
$l = $this->request->getRequestUri();
$arr = explode('/', $l);
$l = $arr[1];
if ($l=='kino') $l = 'kino-svet';
$object = $l;
$model = new ObjectModel($this->db);
$objectinfo = $model->getObjectInfo('/'.$object);
$objectinfo->setSubtitle($objectinfo->getTitle());
$objectinfo->setTitle('Zveřejnění akce');
$objectinfo->setButtons([]);
//pokud nenalezeno, tak 404
if (!$objectinfo->isFound()) return $this->render('/pages/404.html.twig', [
'pageinfo' => $this->pageInfo
]);
$top_events = $this->home_model->getTopEvents();
$facebook_feed = $this->home_model->getFacebookFeed();
return $this->render('/pages/publish_form.html.twig', [
'pageinfo' => $this->pageInfo,
'objectinfo' => $objectinfo,
'top_events' => $top_events,
'facebook_feed' => $facebook_feed,
'g_site_key' => getenv('G_SITE_KEY')
]);
}
/**
* @Route("/kino/{link}")
* @Route("/kino-svet/{link}")
* @Route("/letni-kino/{link}")
* @return Response
* @throws \Facebook\Exceptions\FacebookSDKException
*/
public function event($link): Response
{
$l = $this->request->getRequestUri();
$arr = explode('/', $l);
$l = $arr[1];
if ($l=='kino') $l = 'kino-svet';
// /kino/359134-zachrante-tygra
$objectinfo = $this->object_model->getObjectInfo('/'.$l);
$event = $this->model->getCinemaEvent($link);
//pokud nenalezeno, tak 404
if (!$objectinfo->isFound() || $event->getName()=='') return $this->render('/pages/404.html.twig', [
'pageinfo' => $this->pageInfo
]);
$top_events = $this->home_model->getTopEvents();
$facebook_feed = $this->home_model->getFacebookFeed();
return $this->render('/pages/cinema_event.html.twig', [
'event' => $event,
'pageinfo' => $this->pageInfo,
'objectinfo' => $objectinfo,
'top_events' => $top_events,
'facebook_feed' => $facebook_feed
]);
}
}
?>