Move the logic to check if dest users are required to a dedicated constraint

- Create a dedicated constraint to check if the destUsers are required by the applied transition.
- Apply on WorkflowTransitionContextDTO and, if required, use the built-in constraints
- create tests
This commit is contained in:
2024-10-04 11:35:15 +02:00
parent 7cd638c5fc
commit 7913a377c8
5 changed files with 323 additions and 35 deletions

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserGroup;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Workflow\Validator\TransitionHasDestineeIfIsSentExternal;
use Chill\MainBundle\Workflow\Validator\TransitionHasDestUserIfRequired;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Validator\ThirdPartyHasEmail;
@@ -26,6 +27,7 @@ use Symfony\Component\Workflow\Transition;
* Context for a transition on an workflow entity.
*/
#[TransitionHasDestineeIfIsSentExternal]
#[TransitionHasDestUserIfRequired]
class WorkflowTransitionContextDTO
{
/**
@@ -81,6 +83,7 @@ class WorkflowTransitionContextDTO
])]
public array $futureDestineeEmails = [];
#[Assert\NotNull]
public ?Transition $transition = null;
public string $comment = '';