<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use App\Entity\Image;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class FrontendController extends AbstractController
{
//Animation Department for Gallery
private $params;
public function __construct(ParameterBagInterface $params)
{
$this->params = $params;
}
public function index(EntityManagerInterface $entityManager): Response
{
//Animation Department for Gallery start - finds the directory for the images
// $imageDirectory = $this->params->get('kernel.project_dir') . '/public/upload';
// $images = scandir($imageDirectory);
// $images = array_diff($images, array('..', '.'));
$images = $entityManager->getRepository(Image::class)->fintAllbyAccepted(20); //show maximum 20
//Animation Department for Gallery end
// calculate if the date is past the 1.6.2024
$date = new \DateTime();
$date->setDate(2024, 5, 31);
$date->setTime(0, 0, 0);
$now = new \DateTime();
$now->setTime(0, 0, 0);
// calculate if the date is past the 21.6.2024
$date2 = new \DateTime();
$date2->setDate(2024, 6, 19);
$date2->setTime(0, 0, 0);
if ($now > $date2) // finished the video
{
return $this->render('frontend/index_video_finished.html.twig', [
'controller_name' => 'FrontendController',
'images' => $images,
//Animation Department for Gallery - gives back
]);
} else if ($now > $date ) // producing the video
{
return $this->render('frontend/index_producing.html.twig', [
'controller_name' => 'FrontendController',
//Animation Department for Gallery - gives back
'images' => $images,
]);
} else
{
return $this->render('frontend/index.html.twig', [
'controller_name' => 'FrontendController',
//Animation Department for Gallery - gives back
'images' => $images,
]);
}
}
}