Add support for handling user groups in workflow counters and list workflows in "my workflows" controller

- rewrite queries in repositories;
- fix cache key cleaning for members of users when a workflow is transitionned
This commit is contained in:
2024-09-26 17:44:31 +02:00
parent 87599425df
commit 0c1d9ee4be
5 changed files with 76 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Workflow\Counter;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserGroup;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepRepository;
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
@@ -82,6 +83,18 @@ final readonly class WorkflowByUserCounter implements NotificationCounterInterfa
foreach ($step->getDestUser() as $user) {
$keys[] = self::generateCacheKeyWorkflowByUser($user);
}
foreach ($step->getDestUserGroups()->reduce(
function (array $accumulator, UserGroup $userGroup) {
foreach ($userGroup->getUsers() as $user) {
$accumulator[] = $user;
}
return $accumulator;
},
[]
) as $user) {
$keys[] = self::generateCacheKeyWorkflowByUser($user);
}
if ([] !== $keys) {
$this->cacheItemPool->deleteItems($keys);