diff --git a/config/grid.yaml b/config/grid.yaml index 75ac833b3..30edd11eb 100644 --- a/config/grid.yaml +++ b/config/grid.yaml @@ -123,6 +123,9 @@ services: Pimcore\Bundle\StudioBackendBundle\Grid\Column\Definition\Metadata\DataObjectDefinition: tags: [ 'pimcore.studio_backend.grid_column_definition' ] + Pimcore\Bundle\StudioBackendBundle\Grid\Service\GridSearchServiceInterface: + class: Pimcore\Bundle\StudioBackendBundle\Grid\Service\GridSearchService + # # Column Resolver # diff --git a/src/Asset/Controller/Search/GetSearchResultController.php b/src/Asset/Controller/Search/GetSearchResultController.php new file mode 100644 index 000000000..34d47552b --- /dev/null +++ b/src/Asset/Controller/Search/GetSearchResultController.php @@ -0,0 +1,78 @@ +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)); + } +} diff --git a/src/Filter/MappedParameter/FilterParameter.php b/src/Filter/MappedParameter/FilterParameter.php index 256d13e4e..88eaef83d 100644 --- a/src/Filter/MappedParameter/FilterParameter.php +++ b/src/Filter/MappedParameter/FilterParameter.php @@ -45,6 +45,8 @@ final class FilterParameter implements private ?string $className = null; + private bool $excludeFolders = true; + public function __construct( private readonly int $page = 1, private readonly int $pageSize = 50, @@ -66,7 +68,12 @@ public function getPageSize(): int public function getExcludeFolders(): bool { - return true; + return $this->excludeFolders; + } + + public function setExcludeFolders(bool $excludeFolders): void + { + $this->excludeFolders = $excludeFolders; } public function getPath(): ?string diff --git a/src/Grid/Attribute/Request/SearchGridRequestBody.php b/src/Grid/Attribute/Request/SearchGridRequestBody.php new file mode 100644 index 000000000..65607c29e --- /dev/null +++ b/src/Grid/Attribute/Request/SearchGridRequestBody.php @@ -0,0 +1,55 @@ +columns; + } + + public function getFilters(): FilterParameter + { + return $this->filters ?? new FilterParameter(); + } +} diff --git a/src/Grid/Service/GridSearchService.php b/src/Grid/Service/GridSearchService.php new file mode 100644 index 000000000..1e656455b --- /dev/null +++ b/src/Grid/Service/GridSearchService.php @@ -0,0 +1,48 @@ +getFilters(); + $filter->setExcludeFolders(false); + $parameter = new GridParameter( + folderId: 1, + columns: $gridParameter->getColumns(), + filters: $filter + ); + + return $this->gridService->getAssetGrid($parameter); + } +} diff --git a/src/Grid/Service/GridSearchServiceInterface.php b/src/Grid/Service/GridSearchServiceInterface.php new file mode 100644 index 000000000..d7635bdf0 --- /dev/null +++ b/src/Grid/Service/GridSearchServiceInterface.php @@ -0,0 +1,32 @@ + asset_get_grid_success_response: Asset grid data asset_get_grid_summary: Get asset data for grid +asset_get_search_description: Asset grid for search +asset_get_search_summary: Get asset data for search +asset_get_search_success_response: Assets for search grid asset_get_text_data_by_id_description: | Retrieves the text data in UTF8 representation of the asset based on the given {id}.
The {id} must be an ID of existing asset. asset_get_text_data_by_id_success_response: Successfully retrieved UTF8 encoded text data of asset