mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-28 09:34:59 +00:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user