Adjust logic to only allow on hold if user is allowed to apply a transition

This commit is contained in:
Julie Lenaerts 2024-08-30 11:29:25 +02:00 committed by Julien Fastré
parent 8c5e94e295
commit 46b31ae1ea
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -32,11 +32,21 @@ class WorkflowOnHoldController extends AbstractController
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
$enabledTransitions = $workflow->getEnabledTransitions($entityWorkflow);
$usersInvolved = $entityWorkflow->getUsersInvolved();
if (\count($enabledTransitions) === 0) {
throw $this->createAccessDeniedException('No transitions are available for the current workflow state.');
}
/* if (count($enabledTransitions) > 0) {
$isTransitionAllowed = false;
foreach ($enabledTransitions as $transition) {
if ($workflow->can($entityWorkflow, $transition->getName())) {
$isTransitionAllowed = true;
break;
}
}
}*/
if (!$isTransitionAllowed) {
throw $this->createAccessDeniedException('You are not allowed to apply any transitions to this workflow, therefore you cannot put it on hold.');
}
$stepHold = new EntityWorkflowStepHold($currentStep, $currentUser);