This commit is contained in:
2022-10-05 15:23:28 +02:00
parent 58b1778544
commit a967e1ed17
194 changed files with 1580 additions and 1386 deletions

View File

@@ -41,6 +41,24 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
$this->userRender = $userRender;
}
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 static function getSubscribedEvents(): array
{
return [
@@ -55,23 +73,6 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
];
}
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) {

View File

@@ -57,14 +57,15 @@ class NotificationOnTransition implements EventSubscriberInterface
}
/**
* Send a notification to:
* Send a notification to:.
*
* * the dests of the new step;
* * the users which subscribed to workflow, on each step, or on final
*
* **Warning** take care that this method must be executed **after** the dest users are added to
* the step (@link{EntityWorkflowStep::addDestUser}). Currently, this is done during
* @link{EntityWorkflowTransitionEventSubscriber::addDests}.
* the step (@see{EntityWorkflowStep::addDestUser}). Currently, this is done during
*
* @see{EntityWorkflowTransitionEventSubscriber::addDests}.
*/
public function onCompletedSendNotification(Event $event): void
{
@@ -77,6 +78,7 @@ class NotificationOnTransition implements EventSubscriberInterface
/** @var array<string, User> $dests array of unique values, where keys is the object's hash */
$dests = [];
foreach (array_merge(
// the subscriber to each step
$entityWorkflow->getSubscriberToStep()->toArray(),