getCurrentStep(); $currentUser = $this->security->getUser(); if (!$currentUser instanceof User) { throw new AccessDeniedHttpException('only user can put a workflow on hold'); } $workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName()); $enabledTransitions = $workflow->getEnabledTransitions($entityWorkflow); if (0 === count($enabledTransitions)) { throw new AccessDeniedHttpException('You are not allowed to apply any transitions to this workflow, therefore you cannot toggle the hold status.'); } $stepHold = new EntityWorkflowStepHold($currentStep, $currentUser); $this->entityManager->persist($stepHold); $this->entityManager->flush(); return new RedirectResponse( $this->urlGenerator->generate( 'chill_main_workflow_show', ['id' => $entityWorkflow->getId()] ) ); } #[Route(path: '/{_locale}/main/workflow/{id}/remove_hold', name: 'chill_main_workflow_remove_hold')] public function removeOnHold(EntityWorkflowStep $entityWorkflowStep): Response { $user = $this->security->getUser(); if (!$user instanceof User) { throw new AccessDeniedHttpException('only user can remove workflow on hold'); } if (!$entityWorkflowStep->isOnHoldByUser($user)) { throw new AccessDeniedHttpException('You are not allowed to remove workflow on hold'); } $hold = $entityWorkflowStep->getHoldsOnStep()->findFirst(fn (int $index, EntityWorkflowStepHold $entityWorkflowStepHold) => $user === $entityWorkflowStepHold->getByUser()); if (null === $hold) { // this should not happens... throw new NotFoundHttpException(); } $this->entityManager->remove($hold); $this->entityManager->flush(); return new RedirectResponse( $this->urlGenerator->generate( 'chill_main_workflow_show', ['id' => $entityWorkflowStep->getEntityWorkflow()->getId()] ) ); } }