Send a notification to all User which are members of UserGroups, when a workflow is sent to them

This commit is contained in:
2024-09-26 17:29:27 +02:00
parent 86ec6f82da
commit 87599425df
2 changed files with 26 additions and 21 deletions

View File

@@ -13,6 +13,7 @@ namespace Chill\MainBundle\Workflow\EventSubscriber;
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\Helper\MetadataExtractor;
use Doctrine\ORM\EntityManagerInterface;
@@ -69,7 +70,18 @@ class NotificationOnTransition implements EventSubscriberInterface
// the dests for the current step
$entityWorkflow->getCurrentStep()->getDestUser()->toArray(),
// the cc users for the current step
$entityWorkflow->getCurrentStep()->getCcUser()->toArray()
$entityWorkflow->getCurrentStep()->getCcUser()->toArray(),
// the users within groups
$entityWorkflow->getCurrentStep()->getDestUserGroups()->reduce(
function (array $accumulator, UserGroup $userGroup) {
foreach ($userGroup->getUsers() as $user) {
$accumulator[] = $user;
}
return $accumulator;
},
[]
),
) as $dest) {
$dests[spl_object_hash($dest)] = $dest;
}