mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 00:55:01 +00:00
Add notification to user groups on workflow transition
Implemented NotificationToUserGroupsOnTransition to send group emails upon workflow completion. Also updated NotificationOnTransition to prevent double notifications and created a unit test for the new functionality.
This commit is contained in:
@@ -42,8 +42,8 @@ class NotificationOnTransition implements EventSubscriberInterface
|
||||
/**
|
||||
* Send a notification to:.
|
||||
*
|
||||
* * the dests of the new step;
|
||||
* * the users which subscribed to workflow, on each step, or on final
|
||||
* * the dests of the new step, or the members of a user group if the user group has no email;
|
||||
* * 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 (@see{EntityWorkflowStep::addDestUser}). Currently, this is done during
|
||||
@@ -74,6 +74,11 @@ class NotificationOnTransition implements EventSubscriberInterface
|
||||
// the users within groups
|
||||
$entityWorkflow->getCurrentStep()->getDestUserGroups()->reduce(
|
||||
function (array $accumulator, UserGroup $userGroup) {
|
||||
if ($userGroup->hasEmail()) {
|
||||
// this prevent users to be notified twice if they will already be notiied by the group
|
||||
return $accumulator;
|
||||
}
|
||||
|
||||
foreach ($userGroup->getUsers() as $user) {
|
||||
$accumulator[] = $user;
|
||||
}
|
||||
|
Reference in New Issue
Block a user