|
| 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\Asset\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\Response\DefaultResponses; |
| 26 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; |
| 27 | +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; |
| 28 | +use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes; |
| 29 | +use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions; |
| 30 | +use Symfony\Component\HttpFoundation\JsonResponse; |
| 31 | +use Symfony\Component\Routing\Attribute\Route; |
| 32 | +use Symfony\Component\Security\Http\Attribute\IsGranted; |
| 33 | +use Symfony\Component\Serializer\SerializerInterface; |
| 34 | + |
| 35 | +/** |
| 36 | + * @internal |
| 37 | + */ |
| 38 | +final class GetConfigurationController extends AbstractApiController |
| 39 | +{ |
| 40 | + public function __construct( |
| 41 | + SerializerInterface $serializer, |
| 42 | + private readonly ConfigurationServiceInterface $configurationService, |
| 43 | + ) { |
| 44 | + parent::__construct($serializer); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @throws NotFoundException |
| 49 | + */ |
| 50 | + #[Route( |
| 51 | + '/assets/search/configuration/', |
| 52 | + name: 'pimcore_studio_api_get_asset_search_configuration', |
| 53 | + methods: ['GET'], |
| 54 | + )] |
| 55 | + #[IsGranted(UserPermissions::ASSETS->value)] |
| 56 | + #[Get( |
| 57 | + path: self::PREFIX . '/assets/search/configuration/', |
| 58 | + operationId: 'asset_get_search_configuration', |
| 59 | + description: 'asset_get_search_configuration_description', |
| 60 | + summary: 'asset_get_search_configuration_summary', |
| 61 | + tags: [Tags::AssetSearch->value] |
| 62 | + )] |
| 63 | + #[SuccessResponse( |
| 64 | + description: 'asset_get_search_configuration_success_response', |
| 65 | + content: new JsonContent(ref: DetailedConfiguration::class) |
| 66 | + )] |
| 67 | + #[DefaultResponses([ |
| 68 | + HttpResponseCodes::BAD_REQUEST, |
| 69 | + HttpResponseCodes::UNAUTHORIZED, |
| 70 | + ])] |
| 71 | + public function getAssetGridConfiguration(): JsonResponse |
| 72 | + { |
| 73 | + $configuration = $this->configurationService->getAssetSearchConfiguration(); |
| 74 | + |
| 75 | + return $this->jsonResponse($configuration); |
| 76 | + } |
| 77 | +} |
0 commit comments