diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index e10cac6a4..1f1372cd2 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -300,19 +300,12 @@ class WorkflowController extends AbstractController if (\count($workflow->getEnabledTransitions($entityWorkflow)) > 0) { // possible transition $stepDTO = new WorkflowTransitionContextDTO($entityWorkflow); - $usersInvolved = $entityWorkflow->getUsersInvolved(); - $currentUserFound = array_search($this->security->getUser(), $usersInvolved, true); - - if (false !== $currentUserFound) { - unset($usersInvolved[$currentUserFound]); - } $transitionForm = $this->createForm( WorkflowStepType::class, $stepDTO, [ 'entity_workflow' => $entityWorkflow, - 'suggested_users' => $usersInvolved, ] ); diff --git a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php index e5769a28e..18afc5c58 100644 --- a/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php +++ b/src/Bundle/ChillMainBundle/Form/WorkflowStepType.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Form\Type\PickUserGroupOrUserDynamicType; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; +use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\WorkflowTransitionContextDTO; use Chill\PersonBundle\Form\Type\PickPersonDynamicType; use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType; @@ -34,6 +35,7 @@ class WorkflowStepType extends AbstractType public function __construct( private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper, + private readonly EntityWorkflowManager $entityWorkflowManager, ) {} public function buildForm(FormBuilderInterface $builder, array $options) @@ -43,6 +45,7 @@ class WorkflowStepType extends AbstractType $workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName()); $place = $workflow->getMarking($entityWorkflow); $placeMetadata = $workflow->getMetadataStore()->getPlaceMetadata(array_keys($place->getPlaces())[0]); + $suggestedUsers = $this->entityWorkflowManager->getSuggestedUsers($entityWorkflow); if (null === $options['entity_workflow']) { throw new \LogicException('if transition is true, entity_workflow should be defined'); @@ -157,19 +160,20 @@ class WorkflowStepType extends AbstractType 'label' => 'workflow.signature_zone.user signature', 'multiple' => false, 'suggest_myself' => true, + 'suggested' => $suggestedUsers, ]) ->add('futureDestUsers', PickUserGroupOrUserDynamicType::class, [ 'label' => 'workflow.dest for next steps', 'multiple' => true, 'empty_data' => '[]', - 'suggested' => $options['suggested_users'], + 'suggested' => $suggestedUsers, 'suggest_myself' => true, ]) ->add('futureCcUsers', PickUserDynamicType::class, [ 'label' => 'workflow.cc for next steps', 'multiple' => true, 'required' => false, - 'suggested' => $options['suggested_users'], + 'suggested' => $suggestedUsers, 'empty_data' => '[]', 'attr' => ['class' => 'future-cc-users'], 'suggest_myself' => true, @@ -207,7 +211,6 @@ class WorkflowStepType extends AbstractType $resolver ->setDefault('data_class', WorkflowTransitionContextDTO::class) ->setRequired('entity_workflow') - ->setAllowedTypes('entity_workflow', EntityWorkflow::class) - ->setDefault('suggested_users', []); + ->setAllowedTypes('entity_workflow', EntityWorkflow::class); } }