mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
Move onHold methods to a separate WorkflowOnHold controller
This commit is contained in:
parent
6fc5a10dc4
commit
c1e5f4a57e
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||||
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepHold;
|
||||||
|
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepHoldRepository;
|
||||||
|
use Chill\MainBundle\Security\ChillSecurity;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\Workflow\Registry;
|
||||||
|
|
||||||
|
class WorkflowOnHoldController extends AbstractController
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly EntityManagerInterface $entityManager,
|
||||||
|
private readonly ChillSecurity $security,
|
||||||
|
private readonly Registry $registry,
|
||||||
|
private readonly EntityWorkflowStepHoldRepository $entityWorkflowStepHoldRepository
|
||||||
|
) {}
|
||||||
|
|
||||||
|
#[Route(path: '/{_locale}/main/workflow/{id}/hold', name: 'chill_main_workflow_on_hold')]
|
||||||
|
public function putOnHold(EntityWorkflow $entityWorkflow, Request $request): Response
|
||||||
|
{
|
||||||
|
$currentStep = $entityWorkflow->getCurrentStep();
|
||||||
|
$currentUser = $this->security->getUser();
|
||||||
|
|
||||||
|
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
|
||||||
|
|
||||||
|
$enabledTransitions = $workflow->getEnabledTransitions($entityWorkflow);
|
||||||
|
$usersInvolved = $entityWorkflow->getUsersInvolved();
|
||||||
|
|
||||||
|
/* if (count($enabledTransitions) > 0) {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
$stepHold = new EntityWorkflowStepHold($currentStep, $currentUser);
|
||||||
|
|
||||||
|
$this->entityManager->persist($stepHold);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_main_workflow_show', ['id' => $entityWorkflow->getId()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/{_locale}/main/workflow/{holdId}/remove_hold', name: 'chill_main_workflow_remove_hold')]
|
||||||
|
public function removeOnHold(int $holdId, Request $request): Response
|
||||||
|
{
|
||||||
|
$hold = $this->entityWorkflowStepHoldRepository->findById($holdId);
|
||||||
|
$entityWorkflow = $hold->getStep()->getEntityWorkflow();
|
||||||
|
|
||||||
|
$this->entityManager->remove($hold);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_main_workflow_show', ['id' => $entityWorkflow->getId()]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user