Resolve "Afficher les noms des usagers et l'entité concerné par l'entité notifiée dans la liste des notifications"

This commit is contained in:
2025-01-23 11:34:16 +00:00
committed by Julien Fastré
parent 9e191f1b5b
commit 9a5fd67842
28 changed files with 267 additions and 33 deletions

View File

@@ -17,6 +17,8 @@ use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
class WorkflowNotificationHandler implements NotificationHandlerInterface
{
@@ -29,7 +31,7 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
public function getTemplateData(Notification $notification, array $options = []): array
{
$entityWorkflow = $this->entityWorkflowRepository->find($notification->getRelatedEntityId());
$entityWorkflow = $this->getRelatedEntity($notification);
return [
'entity_workflow' => $entityWorkflow,
@@ -61,4 +63,29 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
{
return EntityWorkflow::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $entityWorkflow = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('workflow.deleted');
}
return new TranslatableMessage($this->entityWorkflowManager->getHandler($entityWorkflow)->getEntityTitle($entityWorkflow));
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $entityWorkflow = $this->getRelatedEntity($notification)) {
return [];
}
$associatedPersons = $this->entityWorkflowManager->getHandler($entityWorkflow)->getEntityData($entityWorkflow)['persons'];
return is_array($associatedPersons) ? $associatedPersons : $associatedPersons->getValues();
}
public function getRelatedEntity(Notification $notification): ?EntityWorkflow
{
return $this->entityWorkflowRepository->find($notification->getRelatedEntityId());
}
}