From a2720b6365b33cf953e73a09822d55126e4b66f1 Mon Sep 17 00:00:00 2001 From: tleon Date: Thu, 4 Apr 2024 17:30:29 +0200 Subject: [PATCH] chore(api): change querybuilder named parameter --- config/admin/services.yml | 18 ++++++++++++++++++ .../Resources/ApiClient/ApiClientList.php | 6 +++--- src/ApiPlatform/Resources/Hook.php | 6 +++--- src/ApiPlatform/Resources/Module/Module.php | 6 +++--- src/ApiPlatform/Resources/ProductList.php | 7 ++++--- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/config/admin/services.yml b/config/admin/services.yml index 4dd6898..9a0df89 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -6,3 +6,21 @@ services: PrestaShop\Module\APIResources\List\ModuleQueryBuilder: parent: 'prestashop.core.grid.abstract_query_builder' autowire: true + + prestashop.core.grid.data_factory.hook: + class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' + public: true + arguments: + - '@prestashop.core.api.query_builder.hook' + - '@prestashop.core.hook.dispatcher' + - '@prestashop.core.grid.query.doctrine_query_parser' + - 'hook' + + prestashop.core.grid.data_factory.module: + class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' + public: true + arguments: + - '@PrestaShop\Module\APIResources\List\ModuleQueryBuilder' + - '@prestashop.core.hook.dispatcher' + - '@prestashop.core.grid.query.doctrine_query_parser' + - 'module' diff --git a/src/ApiPlatform/Resources/ApiClient/ApiClientList.php b/src/ApiPlatform/Resources/ApiClient/ApiClientList.php index 2f274ab..f606ed5 100644 --- a/src/ApiPlatform/Resources/ApiClient/ApiClientList.php +++ b/src/ApiPlatform/Resources/ApiClient/ApiClientList.php @@ -26,11 +26,11 @@ use ApiPlatform\Metadata\ApiResource; use PrestaShop\PrestaShop\Core\Grid\Query\ApiClientQueryBuilder; use PrestaShop\PrestaShop\Core\Search\Filters\ApiClientFilters; -use PrestaShopBundle\ApiPlatform\Metadata\DQBPaginatedList; +use PrestaShopBundle\ApiPlatform\Metadata\PaginatedList; #[ApiResource( operations: [ - new DQBPaginatedList( + new PaginatedList( uriTemplate: '/api-clients', scopes: [ 'api_client_read', @@ -41,7 +41,7 @@ '[client_name]' => '[clientName]', '[external_issuer]' => '[externalIssuer]', ], - queryBuilder: ApiClientQueryBuilder::class, + gridDataFactory: 'prestashop.core.grid.data_factory.api_client', filtersClass: ApiClientFilters::class, filtersMapping: [ '[apiClientId]' => '[id_api_client]', diff --git a/src/ApiPlatform/Resources/Hook.php b/src/ApiPlatform/Resources/Hook.php index 3f6272b..430ccb6 100644 --- a/src/ApiPlatform/Resources/Hook.php +++ b/src/ApiPlatform/Resources/Hook.php @@ -31,7 +31,7 @@ use PrestaShop\PrestaShop\Core\Domain\Hook\Query\GetHookStatus; use PrestaShopBundle\ApiPlatform\Metadata\CQRSGet; use PrestaShopBundle\ApiPlatform\Metadata\CQRSUpdate; -use PrestaShopBundle\ApiPlatform\Metadata\DQBPaginatedList; +use PrestaShopBundle\ApiPlatform\Metadata\PaginatedList; use PrestaShopBundle\ApiPlatform\Provider\QueryListProvider; #[ApiResource( @@ -75,12 +75,12 @@ CQRSQuery: GetHook::class, scopes: ['hook_read'] ), - new DQBPaginatedList( + new PaginatedList( uriTemplate: '/hooks', provider: QueryListProvider::class, scopes: ['hook_read'], ApiResourceMapping: ['[id_hook]' => '[id]'], - queryBuilder: 'prestashop.core.api.query_builder.hook', + gridDataFactory: 'prestashop.core.grid.data_factory.hook', ), ], )] diff --git a/src/ApiPlatform/Resources/Module/Module.php b/src/ApiPlatform/Resources/Module/Module.php index 09e43ba..86be356 100644 --- a/src/ApiPlatform/Resources/Module/Module.php +++ b/src/ApiPlatform/Resources/Module/Module.php @@ -27,7 +27,7 @@ use PrestaShop\Module\APIResources\List\ModuleQueryBuilder; use PrestaShop\PrestaShop\Core\Domain\Module\Query\GetModuleInfos; use PrestaShopBundle\ApiPlatform\Metadata\CQRSGet; -use PrestaShopBundle\ApiPlatform\Metadata\DQBPaginatedList; +use PrestaShopBundle\ApiPlatform\Metadata\PaginatedList; #[ApiResource( operations: [ @@ -38,12 +38,12 @@ 'module_read', ], ), - new DQBPaginatedList( + new PaginatedList( uriTemplate: '/modules', scopes: [ 'module_read', ], - queryBuilder: ModuleQueryBuilder::class, + gridDataFactory: 'prestashop.core.grid.data_factory.module', ), ], )] diff --git a/src/ApiPlatform/Resources/ProductList.php b/src/ApiPlatform/Resources/ProductList.php index 46ea8b3..3cfb2ee 100644 --- a/src/ApiPlatform/Resources/ProductList.php +++ b/src/ApiPlatform/Resources/ProductList.php @@ -25,16 +25,17 @@ use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiResource; +use PrestaShop\PrestaShop\Adapter\Product\Grid\Data\Factory\ProductGridDataFactoryDecorator; use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductNotFoundException; use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\ShopAssociationNotFound; use PrestaShop\PrestaShop\Core\Search\Filters\ProductFilters; -use PrestaShopBundle\ApiPlatform\Metadata\DQBPaginatedList; +use PrestaShopBundle\ApiPlatform\Metadata\PaginatedList; use PrestaShopBundle\ApiPlatform\Provider\QueryListProvider; use Symfony\Component\HttpFoundation\Response; #[ApiResource( operations: [ - new DQBPaginatedList( + new PaginatedList( uriTemplate: '/products', provider: QueryListProvider::class, scopes: ['product_read'], @@ -42,7 +43,7 @@ '[id_product]' => '[productId]', '[final_price_tax_excluded]' => '[price]', ], - queryBuilder: 'prestashop.core.grid.query_builder.product', + gridDataFactory: ProductGridDataFactoryDecorator::class, filtersClass: ProductFilters::class, ), ],