mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
Add user group support in entity workflow steps
Enhanced the WorkflowTransitionContextDTO to include user groups alongside individual users for future steps. Updated the relevant entity and form classes to accommodate this change and included the necessary database migration script.
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserGroup;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
@@ -24,25 +25,25 @@ use Symfony\Component\Workflow\Transition;
|
||||
class WorkflowTransitionContextDTO
|
||||
{
|
||||
/**
|
||||
* a list of future dest users for the next steps.
|
||||
* a list of future dest users or user groups for the next step.
|
||||
*
|
||||
* This is in used in order to let controller inform who will be the future users which will validate
|
||||
* the next step. This is necessary to perform some computation about the next users, before they are
|
||||
* associated to the entity EntityWorkflowStep.
|
||||
*
|
||||
* @var array|User[]
|
||||
* @var list<User|UserGroup>
|
||||
*/
|
||||
public array $futureDestUsers = [];
|
||||
|
||||
/**
|
||||
* a list of future cc users for the next steps.
|
||||
* a list of future cc users for the next step.
|
||||
*
|
||||
* @var array|User[]
|
||||
*/
|
||||
public array $futureCcUsers = [];
|
||||
|
||||
/**
|
||||
* a list of future dest emails for the next steps.
|
||||
* a list of future dest emails for the next step.
|
||||
*
|
||||
* This is in used in order to let controller inform who will be the future emails which will validate
|
||||
* the next step. This is necessary to perform some computation about the next emails, before they are
|
||||
@@ -72,6 +73,22 @@ class WorkflowTransitionContextDTO
|
||||
public EntityWorkflow $entityWorkflow,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return list<User>
|
||||
*/
|
||||
public function getFutureDestUsers(): array
|
||||
{
|
||||
return array_values(array_filter($this->futureDestUsers, fn (User|UserGroup $user) => $user instanceof User));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<UserGroup>
|
||||
*/
|
||||
public function getFutureDestUserGroups(): array
|
||||
{
|
||||
return array_values(array_filter($this->futureDestUsers, fn (User|UserGroup $user) => $user instanceof UserGroup));
|
||||
}
|
||||
|
||||
#[Assert\Callback()]
|
||||
public function validateCCUserIsNotInDest(ExecutionContextInterface $context, $payload): void
|
||||
{
|
||||
|
Reference in New Issue
Block a user