|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +/** |
| 5 | + * This source file is available under the terms of the |
| 6 | + * Pimcore Open Core License (POCL) |
| 7 | + * Full copyright and license information is available in |
| 8 | + * LICENSE.md which is distributed with this source code. |
| 9 | + * |
| 10 | + * @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com) |
| 11 | + * @license Pimcore Open Core License (POCL) |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Controller; |
| 15 | + |
| 16 | +use OpenApi\Attributes\Get; |
| 17 | +use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; |
| 18 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\StringParameter; |
| 19 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; |
| 20 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; |
| 21 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; |
| 22 | +use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes; |
| 23 | +use Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Content\WorkflowStringListContent; |
| 24 | +use Pimcore\Bundle\StudioBackendBundle\Workflow\MappedParameter\WorkflowPlacesParameters; |
| 25 | +use Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowMetaServiceInterface; |
| 26 | +use Symfony\Component\HttpFoundation\JsonResponse; |
| 27 | +use Symfony\Component\HttpKernel\Attribute\MapQueryString; |
| 28 | +use Symfony\Component\Routing\Attribute\Route; |
| 29 | +use Symfony\Component\Serializer\SerializerInterface; |
| 30 | + |
| 31 | +/** |
| 32 | + * @internal |
| 33 | + */ |
| 34 | +final class PlacesCollectionController extends AbstractApiController |
| 35 | +{ |
| 36 | + private const string ROUTE = '/workflows/places'; |
| 37 | + |
| 38 | + public function __construct( |
| 39 | + SerializerInterface $serializer, |
| 40 | + private readonly WorkflowMetaServiceInterface $workflowMetaService, |
| 41 | + ) { |
| 42 | + parent::__construct($serializer); |
| 43 | + } |
| 44 | + |
| 45 | + #[Route(path: self::ROUTE, name: 'pimcore_studio_api_workflows_places', methods: ['GET'])] |
| 46 | + //#[IsGranted('STUDIO_API')] |
| 47 | + #[Get( |
| 48 | + path: self::PREFIX . self::ROUTE, |
| 49 | + operationId: 'workflow_get_places', |
| 50 | + description: 'workflow_get_places_description', |
| 51 | + summary: 'workflow_get_places_summary', |
| 52 | + tags: [Tags::Workflows->name] |
| 53 | + )] |
| 54 | + #[StringParameter('workflowName', 'product_workflow', 'workflow_get_places_workflow_name')] |
| 55 | + #[SuccessResponse( |
| 56 | + description: 'workflow_get_places_success_response', |
| 57 | + content: new WorkflowStringListContent() |
| 58 | + )] |
| 59 | + #[DefaultResponses([ |
| 60 | + HttpResponseCodes::UNAUTHORIZED, |
| 61 | + ])] |
| 62 | + public function getPlaces( |
| 63 | + #[MapQueryString] WorkflowPlacesParameters $parameters = new WorkflowPlacesParameters() |
| 64 | + ): JsonResponse { |
| 65 | + return $this->jsonResponse([ |
| 66 | + 'items' => $this->workflowMetaService->getPlaces($parameters->getWorkflowName()), |
| 67 | + ]); |
| 68 | + } |
| 69 | +} |
0 commit comments