From 5465a6f336377dbe7ca4b39323a85c5ea1c50208 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 24 Jul 2025 15:22:44 +0200 Subject: [PATCH] Create api endpoint to fetch workflow --- .../Controller/WorkflowApiController.php | 3 ++- .../ChillMainExtension.php | 18 +++++++++++++ .../ChillMainBundle/chill.api.specs.yaml | 25 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php index 28dca8016..eee731d98 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowApiController.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Controller; +use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Pagination\PaginatorFactory; @@ -27,7 +28,7 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Security; use Symfony\Component\Serializer\SerializerInterface; -class WorkflowApiController +class WorkflowApiController extends ApiController { public function __construct(private readonly EntityManagerInterface $entityManager, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly SerializerInterface $serializer) {} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 6b33b998d..70f0df071 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -30,6 +30,7 @@ use Chill\MainBundle\Controller\UserGroupAdminController; use Chill\MainBundle\Controller\UserGroupApiController; use Chill\MainBundle\Controller\UserJobApiController; use Chill\MainBundle\Controller\UserJobController; +use Chill\MainBundle\Controller\WorkflowApiController; use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface; use Chill\MainBundle\Doctrine\DQL\Age; use Chill\MainBundle\Doctrine\DQL\Extract; @@ -66,6 +67,7 @@ use Chill\MainBundle\Entity\Regroupment; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserGroup; use Chill\MainBundle\Entity\UserJob; +use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Form\CenterType; use Chill\MainBundle\Form\CivilityType; use Chill\MainBundle\Form\CountryType; @@ -79,6 +81,7 @@ use Chill\MainBundle\Form\UserGroupType; use Chill\MainBundle\Form\UserJobType; use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Security\Authorization\ChillExportVoter; +use Chill\MainBundle\Security\Authorization\EntityWorkflowVoter; use Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType; use Ramsey\Uuid\Doctrine\UuidType; use Symfony\Component\Config\FileLocator; @@ -940,6 +943,21 @@ class ChillMainExtension extends Extension implements ], ], ], + [ + 'class' => EntityWorkflow::class, + 'name' => 'workflow', + 'base_path' => '/api/1.0/main/workflow', + 'base_role' => EntityWorkflowVoter::SEE, + 'controller' => WorkflowApiController::class, + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + ], + ], + ], ], ]); } diff --git a/src/Bundle/ChillMainBundle/chill.api.specs.yaml b/src/Bundle/ChillMainBundle/chill.api.specs.yaml index d87a0eb71..62df1a44c 100644 --- a/src/Bundle/ChillMainBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillMainBundle/chill.api.specs.yaml @@ -965,6 +965,31 @@ paths: application/json: schema: $ref: "#/components/schemas/UserJob" + /1.0/main/workflow/{id}.json: + get: + tags: + - workflow + summary: Return a workflow + parameters: + - name: id + in: path + required: true + description: The workflow id + schema: + type: integer + format: integer + minimum: 1 + responses: + 200: + description: "ok" + content: + application/json: + schema: + $ref: "#/components/schemas/Workflow" + 404: + description: "not found" + 401: + description: "Unauthorized" /1.0/main/workflow/my: get: tags: