Skip to content

Commit

Permalink
chore(api): change querybuilder named parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tleon committed Apr 12, 2024
1 parent 428e5cb commit d949f68
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
18 changes: 18 additions & 0 deletions config/admin/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
7 changes: 3 additions & 4 deletions src/ApiPlatform/Resources/ApiClient/ApiClientList.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@

use ApiPlatform\Metadata\ApiProperty;
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',
Expand All @@ -41,7 +40,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]',
Expand Down
6 changes: 3 additions & 3 deletions src/ApiPlatform/Resources/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
),
],
)]
Expand Down
7 changes: 3 additions & 4 deletions src/ApiPlatform/Resources/Module/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
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: [
Expand All @@ -38,12 +37,12 @@
'module_read',
],
),
new DQBPaginatedList(
new PaginatedList(
uriTemplate: '/modules',
scopes: [
'module_read',
],
queryBuilder: ModuleQueryBuilder::class,
gridDataFactory: 'prestashop.core.grid.data_factory.module',
),
],
)]
Expand Down
7 changes: 4 additions & 3 deletions src/ApiPlatform/Resources/ProductList.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@

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'],
ApiResourceMapping: [
'[id_product]' => '[productId]',
'[final_price_tax_excluded]' => '[price]',
],
queryBuilder: 'prestashop.core.grid.query_builder.product',
gridDataFactory: ProductGridDataFactoryDecorator::class,
filtersClass: ProductFilters::class,
),
],
Expand Down

0 comments on commit d949f68

Please sign in to comment.