mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-29 18:14:59 +00:00
Refactor TaskNotificationHandler
logic
This commit is contained in:
@@ -13,17 +13,14 @@ namespace Chill\TaskBundle\Notification;
|
|||||||
|
|
||||||
use Chill\MainBundle\Entity\Notification;
|
use Chill\MainBundle\Entity\Notification;
|
||||||
use Chill\MainBundle\Notification\NotificationHandlerInterface;
|
use Chill\MainBundle\Notification\NotificationHandlerInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
|
||||||
use Chill\TaskBundle\Entity\SingleTask;
|
use Chill\TaskBundle\Entity\SingleTask;
|
||||||
use Chill\TaskBundle\Repository\SingleTaskAclAwareRepository;
|
|
||||||
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
||||||
use Symfony\Component\Translation\TranslatableMessage;
|
use Symfony\Component\Translation\TranslatableMessage;
|
||||||
use Symfony\Contracts\Translation\TranslatableInterface;
|
use Symfony\Contracts\Translation\TranslatableInterface;
|
||||||
|
|
||||||
final readonly class TaskNotificationHandler implements NotificationHandlerInterface
|
final readonly class TaskNotificationHandler implements NotificationHandlerInterface
|
||||||
{
|
{
|
||||||
public function __construct(private SingleTaskRepository $repository) {}
|
public function __construct(private SingleTaskRepository $taskRepository) {}
|
||||||
|
|
||||||
public function getTemplate(Notification $notification, array $options = []): string
|
public function getTemplate(Notification $notification, array $options = []): string
|
||||||
{
|
{
|
||||||
@@ -34,7 +31,7 @@ final readonly class TaskNotificationHandler implements NotificationHandlerInter
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'notification' => $notification,
|
'notification' => $notification,
|
||||||
'task' => $this->repository->find($notification->getRelatedEntityId()),
|
'task' => $this->taskRepository->find($notification->getRelatedEntityId()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,11 +55,15 @@ final readonly class TaskNotificationHandler implements NotificationHandlerInter
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $task->get;
|
if (null !== $task->getCourse()) {
|
||||||
|
return $task->getCourse()->getParticipations()->getValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRelatedEntity(Notification $notification): ?AccompanyingPeriod
|
return [$task->getPerson()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelatedEntity(Notification $notification): ?SingleTask
|
||||||
{
|
{
|
||||||
return $this->accompanyingPeriodRepository->find($notification->getRelatedEntityId());
|
return $this->taskRepository->find($notification->getRelatedEntityId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user