From aaf8cfeb6c4d908c8129d78185f0cdfb5b8b9a10 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 | 21 ++++++++++++++++++++- src/ApiPlatform/Resources/Hook.php | 2 +- src/ApiPlatform/Resources/Module/Module.php | 2 +- src/ApiPlatform/Resources/ProductList.php | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config/admin/services.yml b/config/admin/services.yml index 4dd6898..c5929b6 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -3,6 +3,25 @@ services: public: false autowire: true - PrestaShop\Module\APIResources\List\ModuleQueryBuilder: + prestashop.module.api.list.module_query_builder: + class: '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.api.list.module_query_builder' + - '@prestashop.core.hook.dispatcher' + - '@prestashop.core.grid.query.doctrine_query_parser' + - 'module' diff --git a/src/ApiPlatform/Resources/Hook.php b/src/ApiPlatform/Resources/Hook.php index 3f6272b..6cc884b 100644 --- a/src/ApiPlatform/Resources/Hook.php +++ b/src/ApiPlatform/Resources/Hook.php @@ -80,7 +80,7 @@ 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..eb56cf4 100644 --- a/src/ApiPlatform/Resources/Module/Module.php +++ b/src/ApiPlatform/Resources/Module/Module.php @@ -43,7 +43,7 @@ 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..8d2076d 100644 --- a/src/ApiPlatform/Resources/ProductList.php +++ b/src/ApiPlatform/Resources/ProductList.php @@ -25,6 +25,7 @@ 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; @@ -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, ), ],