|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +/** |
| 5 | + * Pimcore |
| 6 | + * |
| 7 | + * This source file is available under two different licenses: |
| 8 | + * - GNU General Public License version 3 (GPLv3) |
| 9 | + * - Pimcore Commercial License (PCL) |
| 10 | + * Full copyright and license information is available in |
| 11 | + * LICENSE.md which is distributed with this source code. |
| 12 | + * |
| 13 | + * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) |
| 14 | + * @license http://www.pimcore.org/license GPLv3 and PCL |
| 15 | + */ |
| 16 | + |
| 17 | +namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Controller\Search; |
| 18 | + |
| 19 | +use OpenApi\Attributes\Get; |
| 20 | +use OpenApi\Attributes\JsonContent; |
| 21 | +use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; |
| 22 | +use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; |
| 23 | +use Pimcore\Bundle\StudioBackendBundle\Grid\Schema\DetailedConfiguration; |
| 24 | +use Pimcore\Bundle\StudioBackendBundle\Grid\Service\ConfigurationServiceInterface; |
| 25 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\StringParameter; |
| 26 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; |
| 27 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; |
| 28 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; |
| 29 | +use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes; |
| 30 | +use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions; |
| 31 | +use Symfony\Component\HttpFoundation\JsonResponse; |
| 32 | +use Symfony\Component\Routing\Attribute\Route; |
| 33 | +use Symfony\Component\Security\Http\Attribute\IsGranted; |
| 34 | +use Symfony\Component\Serializer\SerializerInterface; |
| 35 | + |
| 36 | +/** |
| 37 | + * @internal |
| 38 | + */ |
| 39 | +final class GetConfigurationController extends AbstractApiController |
| 40 | +{ |
| 41 | + public function __construct( |
| 42 | + SerializerInterface $serializer, |
| 43 | + private readonly ConfigurationServiceInterface $gridConfigurationService, |
| 44 | + ) { |
| 45 | + parent::__construct($serializer); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @throws NotFoundException |
| 50 | + */ |
| 51 | + #[Route( |
| 52 | + '/data-object/search/configuration/{classId?}', |
| 53 | + name: 'pimcore_studio_api_get_data_object_search_configuration', |
| 54 | + methods: ['GET'], |
| 55 | + |
| 56 | + )] |
| 57 | + #[IsGranted(UserPermissions::DATA_OBJECTS->value)] |
| 58 | + #[Get( |
| 59 | + path: self::PREFIX . '/data-object/search/configuration/{classId}', |
| 60 | + operationId: 'data_object_get_search_configuration', |
| 61 | + description: 'data_object_get_search_configuration_description', |
| 62 | + summary: 'data_object_get_search_configuration_summary', |
| 63 | + tags: [Tags::DataObjectsSearch->value] |
| 64 | + )] |
| 65 | + #[StringParameter( |
| 66 | + name: 'classId', |
| 67 | + example: 'EV', |
| 68 | + description: 'Class Id of the data object', |
| 69 | + required: false, |
| 70 | + )] |
| 71 | + #[SuccessResponse( |
| 72 | + description: 'data_object_get_search_configuration_success_response', |
| 73 | + content: new JsonContent(ref: DetailedConfiguration::class) |
| 74 | + )] |
| 75 | + #[DefaultResponses([ |
| 76 | + HttpResponseCodes::BAD_REQUEST, |
| 77 | + HttpResponseCodes::NOT_FOUND, |
| 78 | + HttpResponseCodes::UNAUTHORIZED, |
| 79 | + ])] |
| 80 | + public function getDataObjectSearchConfiguration(?string $classId): JsonResponse |
| 81 | + { |
| 82 | + $configuration = $this->gridConfigurationService->getDataObjectSearchConfiguration($classId); |
| 83 | + |
| 84 | + return $this->jsonResponse($configuration); |
| 85 | + } |
| 86 | +} |
0 commit comments