|
13 | 13 |
|
14 | 14 | final class ListPerPage implements CapacityInterface |
15 | 15 | { |
16 | | - private static array $endpoints = [ |
| 16 | + private static array $endpointsLegacy = [ |
17 | 17 | // Simple resources Endpoints |
18 | 18 | 'channels', |
19 | 19 | 'countries', |
@@ -41,26 +41,110 @@ final class ListPerPage implements CapacityInterface |
41 | 41 | 'zones', |
42 | 42 | ]; |
43 | 43 |
|
44 | | - private static array $doubleEndpoints = [ |
| 44 | + private static array $endpointsAdmin = [ |
| 45 | + // Simple Ressource Endpoints |
| 46 | + 'adjustment', |
| 47 | + 'administrator', |
| 48 | + 'catalogPromotion', |
| 49 | + 'channel', |
| 50 | + 'country', |
| 51 | + 'currency', |
| 52 | + 'customerGroup', |
| 53 | + 'exchangeRate', |
| 54 | + 'locale', |
| 55 | + 'order', |
| 56 | + 'payment', |
| 57 | + 'product', |
| 58 | + 'productAssociationType', |
| 59 | + 'productImage', |
| 60 | + 'productOption', |
| 61 | + 'productOptionValue', |
| 62 | + 'productReview', |
| 63 | + 'productTaxon', |
| 64 | + 'productVariant', |
| 65 | + 'promotion', |
| 66 | + 'province', |
| 67 | + 'shipment', |
| 68 | + 'shippingCategory', |
| 69 | + 'shippingMethod', |
| 70 | + 'ShopBillingData', |
| 71 | + 'taxCategory', |
| 72 | + 'taxon', |
| 73 | + 'taxonTranslation', |
| 74 | + 'zone', |
| 75 | + 'zoneMember', |
| 76 | + ]; |
| 77 | + |
| 78 | + private static array $endpointsShop = [ |
| 79 | + // Simple Ressource Endpoints |
| 80 | + 'address', |
| 81 | + 'adjustment', |
| 82 | + 'country', |
| 83 | + 'currency', |
| 84 | + 'locale', |
| 85 | + 'order', |
| 86 | + 'orderItem', |
| 87 | + 'payment', |
| 88 | + 'paymentMethod', |
| 89 | + 'product', |
| 90 | + 'productReview', |
| 91 | + 'productVariant', |
| 92 | + 'shipment', |
| 93 | + 'shippingMethod', |
| 94 | + 'taxon', |
| 95 | + ]; |
| 96 | + |
| 97 | + private static array $doubleEndpointsLegacy = [ |
45 | 98 | // Double resources Endpoints |
46 | 99 | 'productReviews', |
47 | 100 | 'productVariants', |
48 | 101 | 'promotionCoupons', |
49 | 102 | ]; |
| 103 | + private static array $doubleEndpointsAdmin = [ |
| 104 | + // Double resources Endpoints |
| 105 | + 'adjustment', |
| 106 | + 'province', |
| 107 | + 'shopBillingData', |
| 108 | + 'zoneMember', |
| 109 | + ]; |
| 110 | + |
| 111 | + private static array $doubleEndpointsShop = [ |
| 112 | + // Double resources Endpoints |
| 113 | + 'adjustment', |
| 114 | + 'order', |
| 115 | + ]; |
50 | 116 |
|
51 | 117 | public function __construct(private readonly ExpressionLanguage $interpreter) |
52 | 118 | { |
53 | 119 | } |
54 | 120 |
|
55 | 121 | public function applies(array $config): bool |
56 | 122 | { |
| 123 | + switch($config['api_type']) { |
| 124 | + case 'admin': |
| 125 | + $endpoints = self::$endpointsAdmin; |
| 126 | + $doubleEndpoints = self::$doubleEndpointsAdmin; |
| 127 | + break; |
| 128 | + case 'shop': |
| 129 | + $endpoints = self::$endpointsShop; |
| 130 | + $doubleEndpoints = self::$doubleEndpointsShop; |
| 131 | + break; |
| 132 | + case 'legacy': |
| 133 | + $endpoints = self::$endpointsLegacy; |
| 134 | + $doubleEndpoints = self::$doubleEndpointsLegacy; |
| 135 | + break; |
| 136 | + default: |
| 137 | + $endpoints = []; |
| 138 | + $doubleEndpoints = []; |
| 139 | + break; |
| 140 | + } |
57 | 141 | return isset($config['type']) |
58 | | - && (\in_array($config['type'], self::$endpoints) || \in_array($config['type'], self::$doubleEndpoints)) |
| 142 | + && (\in_array($config['type'], $endpoints) || \in_array($config['type'], $doubleEndpoints)) |
59 | 143 | && isset($config['method']) |
60 | 144 | && 'listPerPage' === $config['method']; |
61 | 145 | } |
62 | 146 |
|
63 | | - private function compileFilters(array ...$filters): Node |
| 147 | + private function compileFilters(array ...$filters): Node\Expr |
64 | 148 | { |
65 | 149 | $builder = new Sylius\Builder\Search(); |
66 | 150 | foreach ($filters as $filter) { |
|
0 commit comments