src/Controller/Public/EventController.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\Public;
  4. use App\Repository\EventRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class EventController extends AbstractController {
  9.     #[Route('/evenementen', name: 'events')]
  10.     public function index(EventRepository $eventRepository): Response {
  11.         $now = (new \DateTime())->setTimezone(new \DateTimeZone("Europe/Brussels"));
  12.         $time = $now->format("H:i:s");
  13.         $date = $now->format("Y-m-d");
  14.         return $this->render("/public/event/index.html.twig", [
  15.             "events" => $eventRepository->findByDate($date, $time)
  16.         ]);
  17.     }
  18. }