Files
Classeo/backend/src/Scolarite/Application/Command/TruncateSlotRecurrence/TruncateSlotRecurrenceHandler.php
Mathias STRASSER ae640e91ac
Some checks failed
CI / Backend Tests (push) Has been cancelled
CI / Frontend Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Naming Conventions (push) Has been cancelled
CI / Build Check (push) Has been cancelled
feat: Permettre la définition d'une semaine type récurrente pour l'emploi du temps
Les administrateurs devaient recréer manuellement l'emploi du temps chaque
semaine. Cette implémentation introduit un système de récurrence hebdomadaire
avec gestion des exceptions par occurrence, permettant de modifier ou annuler
un cours spécifique sans affecter les autres semaines.

Le ScheduleResolver calcule dynamiquement l'EDT réel en combinant les créneaux
récurrents, les exceptions ponctuelles et le calendrier scolaire (vacances/fériés).
2026-03-05 02:36:34 +01:00

39 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Scolarite\Application\Command\TruncateSlotRecurrence;
use App\Scolarite\Domain\Exception\DateExceptionInvalideException;
use App\Scolarite\Domain\Model\Schedule\ScheduleSlotId;
use App\Scolarite\Domain\Repository\ScheduleSlotRepository;
use App\Shared\Domain\Clock;
use App\Shared\Domain\Tenant\TenantId;
use DateTimeImmutable;
final readonly class TruncateSlotRecurrenceHandler
{
public function __construct(
private ScheduleSlotRepository $slotRepository,
private Clock $clock,
) {
}
public function __invoke(TruncateSlotRecurrenceCommand $command): void
{
$tenantId = TenantId::fromString($command->tenantId);
$slotId = ScheduleSlotId::fromString($command->slotId);
$slot = $this->slotRepository->get($slotId, $tenantId);
$fromDate = new DateTimeImmutable($command->fromDate);
if (!$slot->isActiveOnDate($fromDate)) {
throw DateExceptionInvalideException::pourSlotEtDate($slotId, $fromDate);
}
$now = $this->clock->now();
$dayBefore = $fromDate->modify('-1 day');
$slot->terminerRecurrenceLe($dayBefore, $now);
$this->slotRepository->save($slot);
}
}