mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
Add entity workflow title to notification
Introduced `EntityWorkflowManager` to `NotificationOnTransition` to fetch and include the entity workflow title in notifications. Updated relevant tests to support the new functionality and verify the entity title retrieval process.
This commit is contained in:
@@ -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<string, User> $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();
|
||||
|
Reference in New Issue
Block a user