Do not block transition in EntityWorkflow when the user is member of a dest user group

- refactor EntityWorkflowGuardTransition + tests
- allow to find easily user within userGroup by adding a dedicated method to UserGroup::contains
This commit is contained in:
2024-09-26 16:04:53 +02:00
parent 17f4c85fa5
commit 86ec6f82da
4 changed files with 44 additions and 1 deletions

View File

@@ -141,4 +141,9 @@ class UserGroup
{
return true;
}
public function contains(User $user): bool
{
return $this->users->contains($user);
}
}

View File

@@ -203,7 +203,9 @@ class EntityWorkflowStep
/**
* get all the users which are allowed to apply a transition: those added manually, and
* those added automatically bu using an access key.
* those added automatically by using an access key.
*
* This method exclude the users associated with user groups
*
* @psalm-suppress DuplicateArrayKey
*/
@@ -217,6 +219,14 @@ class EntityWorkflowStep
);
}
/**
* @return Collection<int, UserGroup>
*/
public function getDestUserGroups(): Collection
{
return $this->destUserGroups;
}
public function getCcUser(): Collection
{
return $this->ccUser;