Fix: Workflow: the notification is send when the user is added on first

step.

See https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/813
This commit is contained in:
2022-09-19 21:27:07 +02:00
parent 5b148f967f
commit 6bd0bcff6e
5 changed files with 152 additions and 21 deletions

View File

@@ -45,13 +45,33 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
{
return [
'workflow.transition' => 'onTransition',
'workflow.completed' => 'onCompleted',
'workflow.completed' => [
['markAsFinal', 2048],
['addDests', 2048],
],
'workflow.guard' => [
['guardEntityWorkflow', 0],
],
];
}
public function addDests(Event $event): void
{
if (!$event->getSubject() instanceof EntityWorkflow) {
return;
}
/** @var EntityWorkflow $entityWorkflow */
$entityWorkflow = $event->getSubject();
foreach ($entityWorkflow->futureDestUsers as $user) {
$entityWorkflow->getCurrentStep()->addDestUser($user);
}
foreach ($entityWorkflow->futureDestEmails as $email) {
$entityWorkflow->getCurrentStep()->addDestEmail($email);
}
}
public function guardEntityWorkflow(GuardEvent $event)
{
if (!$event->getSubject() instanceof EntityWorkflow) {
@@ -90,7 +110,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
}
}
public function onCompleted(Event $event): void
public function markAsFinal(Event $event): void
{
if (!$event->getSubject() instanceof EntityWorkflow) {
return;