-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGetSearchResultController.php
More file actions
78 lines (73 loc) · 3.01 KB
/
GetSearchResultController.php
File metadata and controls
78 lines (73 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types=1);
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Search;
use OpenApi\Attributes\Post;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
use Pimcore\Bundle\StudioBackendBundle\Grid\Attribute\Property\GridCollection;
use Pimcore\Bundle\StudioBackendBundle\Grid\Attribute\Request\SearchGridRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Grid\MappedParameter\SearchGridParameter;
use Pimcore\Bundle\StudioBackendBundle\Grid\Service\GridSearchServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\CollectionJson;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @internal
*/
final class GetSearchResultController extends AbstractApiController
{
public function __construct(
SerializerInterface $serializer,
private readonly GridSearchServiceInterface $searchService,
) {
parent::__construct($serializer);
}
/**
* @throws InvalidArgumentException
*/
#[Route('/assets/search', name: 'pimcore_studio_api_get_asset_search', methods: ['POST'])]
#[IsGranted(UserPermissions::ASSETS->value)]
#[Post(
path: self::PREFIX . '/assets/search',
operationId: 'asset_get_search',
description: 'asset_get_search_description',
summary: 'asset_get_search_summary',
tags: [Tags::AssetSearch->value]
)]
#[SearchGridRequestBody]
#[SuccessResponse(
description: 'asset_get_search_success_response',
content: new CollectionJson(
collection: new GridCollection()
)
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
HttpResponseCodes::BAD_REQUEST,
])]
public function getAssetGrid(#[MapRequestPayload] SearchGridParameter $searchGridParameter): JsonResponse
{
return $this->jsonResponse($this->searchService->getAssetSearchGrid($searchGridParameter));
}
}