/
AleksWork
/
diary_plants
Обзор
Документация
Войти
/
AleksWork
/
diary_plants
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/Application/MessageHandler/ClearOldIncidentsHandler.php
22 строки
653 B
AlexeySerov
Add incident days to keep parametr to service yaml for use with console incident command and handler
27 май 2026, 13:12
27 май 2026, 13:12
e998849
Код
Авторство
О чём код?
<?php namespace App\Application\MessageHandler; use DateTimeImmutable; use App\Application\Message\ClearOldIncidentsMessage; use App\Domain\Repository\IncidentRepositoryInterface; use Symfony\Component\Messenger\Attribute\AsMessageHandler; #[AsMessageHandler] final readonly class ClearOldIncidentsHandler { public function __construct( private IncidentRepositoryInterface $incidentRepository ) {} public function __invoke(ClearOldIncidentsMessage $message): void { $dateLimit = new DateTimeImmutable(sprintf('-%d days', $message->daysToKeep)); $this->incidentRepository->deleteOlderThan($dateLimit); } }