40 lines
997 B
PHP
40 lines
997 B
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\Filesystem\Filesystem;
|
|
use App\Motion\SnapshotRepository;
|
|
|
|
class EventController extends AbstractController
|
|
{
|
|
/**
|
|
* @Route("/events/{date}", name="events")
|
|
*/
|
|
public function events(SnapshotRepository $snapshotRepository, string $date = null)
|
|
{
|
|
$date = $date ?? date('Y-m-d');
|
|
|
|
$snapshots = $snapshotRepository->find([
|
|
'order' => 'DESC',
|
|
]);
|
|
|
|
$days = [];
|
|
|
|
foreach ($snapshots as $snapshot) {
|
|
$day = $snapshot->getDate()->format('d/m');
|
|
|
|
if (!in_array($day, $days)) {
|
|
$days[$snapshot->getDate()->format('Y-m-d')] = $day;
|
|
}
|
|
}
|
|
|
|
return $this->render('events.html.twig', [
|
|
'snapshots' => $snapshots,
|
|
'days' => $days,
|
|
'date' => $date,
|
|
]);
|
|
}
|
|
}
|