diff --git a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php index e2fc30da8..9f90c5b12 100644 --- a/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Workflow/EventSubscriber/NotificationOnTransitionTest.php @@ -16,6 +16,8 @@ use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserGroup; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep; +use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; +use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\EventSubscriber\NotificationOnTransition; use Chill\MainBundle\Workflow\Helper\MetadataExtractor; use Doctrine\ORM\EntityManagerInterface; @@ -91,12 +93,18 @@ final class NotificationOnTransitionTest extends TestCase $security = $this->prophesize(Security::class); $security->getUser()->willReturn($currentUser); + $entityWorkflowHandler = $this->prophesize(EntityWorkflowHandlerInterface::class); + $entityWorkflowHandler->getEntityTitle($entityWorkflow)->willReturn('workflow title'); + $entityWorkflowManager = $this->prophesize(EntityWorkflowManager::class); + $entityWorkflowManager->getHandler($entityWorkflow)->willReturn($entityWorkflowHandler->reveal()); + $notificationOnTransition = new NotificationOnTransition( $em->reveal(), $engine->reveal(), $extractor->reveal(), $security->reveal(), - $registry->reveal() + $registry->reveal(), + $entityWorkflowManager->reveal(), ); $event = new Event($entityWorkflow, new Marking(), new Transition('dummy_transition', ['from_state'], ['to_state']), $workflow); diff --git a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php index 5e33fc3c0..63482ddff 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php +++ b/src/Bundle/ChillMainBundle/Workflow/EventSubscriber/NotificationOnTransition.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserGroup; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; +use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\Helper\MetadataExtractor; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -30,6 +31,7 @@ class NotificationOnTransition implements EventSubscriberInterface private readonly MetadataExtractor $metadataExtractor, private readonly Security $security, private readonly Registry $registry, + private EntityWorkflowManager $entityWorkflowManager, ) {} public static function getSubscribedEvents(): array @@ -62,6 +64,8 @@ class NotificationOnTransition implements EventSubscriberInterface /** @var array $dests array of unique values, where keys is the object's hash */ $dests = []; + $title = $this->entityWorkflowManager->getHandler($entityWorkflow)->getEntityTitle($entityWorkflow); + foreach (array_merge( // the subscriber to each step $entityWorkflow->getSubscriberToStep()->toArray(), @@ -112,6 +116,7 @@ class NotificationOnTransition implements EventSubscriberInterface static fn (User $u) => $u->getId(), $entityWorkflow->getCurrentStep()->getDestUser()->toArray() ), true), + 'title' => $title, ]; $notification = new Notification();