Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
716cf56cb2.url-de-test.ws
/
htdocs
/
src
/
Service
/
/srv/data/web/vhosts/716cf56cb2.url-de-test.ws/htdocs/src/Service/ValidateDates.php
<?php namespace App\Service; use App\Entity\Saison; use App\Repository\SaisonRepository; use Symfony\Component\HttpFoundation\Session\SessionInterface; class ValidateDates { protected $saisonRepository; protected $session; public function __construct(SaisonRepository $saisonRepository, SessionInterface $session) { $this->saisonRepository = $saisonRepository; $this->session = $session; } public function validate($data) { $starDate = $data['start']; $endDate = $data['end']; if ($starDate >= $endDate) { $this->session->getFlashBag()->add('danger', 'Veuillez choisir des dates correctes'); return false; } $saisons = $this->saisonRepository->findCurrentSaison($data['start']); if ($saisons && $saisons[0]->getName() === Saison::HAUTE_SAISON) { return $this->validateMinWeek($data, $saisons[0]); } else { return $this->validateMinThreeDays($data); } } public function validateMinWeek($data) { $starDate = $data['start']; $endDate = $data['end']; $difference = $starDate->diff($endDate)->days; if ($difference < 7) { $this->session->getFlashBag()->add('danger', 'Vous devez rester au moins 7 nuits pendant la saison haute'); return false; } return true; } public function validateMinThreeDays($data) { $starDate = $data['start']; $endDate = $data['end']; $difference = $starDate->diff($endDate)->days; if ($difference < 3) { $this->session->getFlashBag()->add('danger', 'Vous devez rester au moins 3 nuits'); return false; } return true; } public function beforeOneMonth($data) { $starDate = $data['start']; $today = new \DateTimeImmutable(); $difference = $starDate->diff($today)->days; if ($difference < 30) { return false; } return true; } }