diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_content_to_user_group.fr.txt.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_content_to_user_group.fr.txt.twig index b97fbf359..e812f6901 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_content_to_user_group.fr.txt.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_content_to_user_group.fr.txt.twig @@ -2,8 +2,14 @@ Chers membres du groupe {{ user_group.label|localize_translatable_string }}, Un suivi "{{ workflow.text }}" a atteint une nouvelle étape: {{ place.text }} -Vous pouvez visualiser le workflow sur cette page: +Titre du workflow: "{{ title }}". + +Vous êtes invité·e à valider cette étape. Pour obtenir un accès, vous pouvez cliquer sur le lien suivant: {{ absolute_url(path('chill_main_workflow_grant_access_by_key', {'id': entity_workflow.currentStep.id, '_locale': 'fr', 'accessKey': entity_workflow.currentStep.accessKey})) }} +Dès que vous aurez cliqué une fois sur le lien, vous serez autorisé à valider cette étape. + +Notez que vous devez disposer d'un compte utilisateur valide dans Chill. + Cordialement, diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_title.fr.txt.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_title.fr.txt.twig index 4960b6138..d4422af7a 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_title.fr.txt.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/workflow_notification_on_transition_completed_title.fr.txt.twig @@ -1,5 +1,5 @@ {%- if is_dest -%} -Un suivi {{ workflow.text }} demande votre attention +Un suivi {{ workflow.text }} demande votre attention: {{ title }} {%- else -%} Un suivi {{ workflow.text }} a atteint une nouvelle étape: {{ place.text }} {%- endif -%} diff --git a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationToUserGroupsOnTransitionTest.php b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationToUserGroupsOnTransitionTest.php index ffa102978..0c781d311 100644 --- a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationToUserGroupsOnTransitionTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationToUserGroupsOnTransitionTest.php @@ -14,6 +14,8 @@ namespace Chill\MainBundle\Tests\Workflow\EventSubscriber; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserGroup; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; +use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; +use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\EntityWorkflowMarkingStore; use Chill\MainBundle\Workflow\EventSubscriber\NotificationToUserGroupsOnTransition; use Chill\MainBundle\Workflow\Helper\MetadataExtractor; @@ -82,7 +84,12 @@ class NotificationToUserGroupsOnTransitionTest extends KernelTestCase $metadataExtractor->buildArrayPresentationForWorkflow(Argument::type(Workflow::class))->willReturn(['name' => 'dummy', 'text' => 'Dummy Workflow']); $metadataExtractor->buildArrayPresentationForPlace($entityWorkflow)->willReturn(['name' => 'to_one', 'text' => 'Dummy Place']); - $registry = $this->buildRegistryWithEventSubscriber($mailer->reveal(), $metadataExtractor->reveal()); + $entityWorkflowHandler = $this->prophesize(EntityWorkflowHandlerInterface::class); + $entityWorkflowHandler->getEntityTitle($entityWorkflow)->willReturn('My title'); + $entityWorkflowManager = $this->prophesize(EntityWorkflowManager::class); + $entityWorkflowManager->getHandler($entityWorkflow)->willReturn($entityWorkflowHandler->reveal()); + + $registry = $this->buildRegistryWithEventSubscriber($mailer->reveal(), $metadataExtractor->reveal(), $entityWorkflowManager->reveal()); $workflow = $registry->get($entityWorkflow, 'dummy'); $workflow->apply($entityWorkflow, 'to_one', ['context' => $dto, 'transition' => 'to_one', 'transitionAt' => new \DateTimeImmutable(), 'byUser' => new User()]); @@ -106,13 +113,18 @@ class NotificationToUserGroupsOnTransitionTest extends KernelTestCase $metadataExtractor->buildArrayPresentationForWorkflow(Argument::type(Workflow::class))->willReturn(['name' => 'dummy', 'text' => 'Dummy Workflow']); $metadataExtractor->buildArrayPresentationForPlace($entityWorkflow)->willReturn(['name' => 'to_one', 'text' => 'Dummy Place']); - $registry = $this->buildRegistryWithEventSubscriber($mailer->reveal(), $metadataExtractor->reveal()); + $entityWorkflowHandler = $this->prophesize(EntityWorkflowHandlerInterface::class); + $entityWorkflowHandler->getEntityTitle($entityWorkflow)->willReturn('My title'); + $entityWorkflowManager = $this->prophesize(EntityWorkflowManager::class); + $entityWorkflowManager->getHandler($entityWorkflow)->willReturn($entityWorkflowHandler->reveal()); + + $registry = $this->buildRegistryWithEventSubscriber($mailer->reveal(), $metadataExtractor->reveal(), $entityWorkflowManager->reveal()); $workflow = $registry->get($entityWorkflow, 'dummy'); $workflow->apply($entityWorkflow, 'to_one', ['context' => $dto, 'transition' => 'to_one', 'transitionAt' => new \DateTimeImmutable(), 'byUser' => new User()]); } - private function buildRegistryWithEventSubscriber(MailerInterface $mailer, MetadataExtractor $metadataExtractor): Registry + private function buildRegistryWithEventSubscriber(MailerInterface $mailer, MetadataExtractor $metadataExtractor, EntityWorkflowManager $entityWorkflowManager): Registry { $builder = new DefinitionBuilder(); $builder @@ -134,7 +146,7 @@ class NotificationToUserGroupsOnTransitionTest extends KernelTestCase } }); - $notificationEventSubscriber = new NotificationToUserGroupsOnTransition($this->twig, $metadataExtractor, $registry, $mailer, $this->em); + $notificationEventSubscriber = new NotificationToUserGroupsOnTransition($this->twig, $metadataExtractor, $registry, $mailer, $this->em, $entityWorkflowManager); $eventDispatcher->addSubscriber($notificationEventSubscriber); return $registry; diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationToUserGroupsOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationToUserGroupsOnTransition.php index 63682ec1a..1eebb03a6 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationToUserGroupsOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationToUserGroupsOnTransition.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Workflow\EventSubscriber; use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; +use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\Helper\MetadataExtractor; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bridge\Twig\Mime\TemplatedEmail; @@ -29,6 +30,7 @@ final readonly class NotificationToUserGroupsOnTransition implements EventSubscr private Registry $registry, private MailerInterface $mailer, private EntityManagerInterface $entityManager, + private EntityWorkflowManager $entityWorkflowManager, ) {} public static function getSubscribedEvents(): array @@ -62,6 +64,7 @@ final readonly class NotificationToUserGroupsOnTransition implements EventSubscr $workflow = $this->metadataExtractor->buildArrayPresentationForWorkflow( $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName()) ); + $title = $this->entityWorkflowManager->getHandler($entityWorkflow)->getEntityTitle($entityWorkflow); $currentStep = $entityWorkflow->getCurrentStep(); if (!$this->entityManager->contains($currentStep)) { @@ -81,6 +84,7 @@ final readonly class NotificationToUserGroupsOnTransition implements EventSubscr 'place' => $place, 'workflow' => $workflow, 'is_dest' => true, + 'title' => $title, ]; $email = new TemplatedEmail();