Skip to content

Commit fb97d5a

Browse files
committed
Restore API field constants and replace hardcoded query tokens
1 parent 7fdc80b commit fb97d5a

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/base/types/Api.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ abstract class Api extends Singleton
2525
{
2626
use ManagerTrait, ApiListTrait, ApiCrudResponseTrait;
2727

28+
const API_COMBO_FIELD = '__combo';
2829
const API_LIST_NAME_FIELD = '__name__';
2930
const API_FIELDS_RESULT_FIELD = '__fields';
3031
const API_MODEL_KEY_FIELD = '__pk';
32+
const API_ORDER_FIELD = '__order';
33+
const API_PAGE_FIELD = '__page';
34+
const API_LIMIT_FIELD = '__limit';
3135
const API_PK_SEPARATOR = '__|__';
3236

3337
const API_ACTION_LIST = 'list';

src/base/types/traits/Api/ApiEndpointExtractorTrait.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Exception;
66
use PSFS\base\Logger;
77
use PSFS\base\Request;
8+
use PSFS\base\types\Api;
89
use PSFS\base\types\helpers\AnnotationHelper;
910
use PSFS\base\types\helpers\MetadataReader;
1011
use PSFS\base\types\helpers\attributes\Header;
@@ -148,21 +149,21 @@ private function buildNativeQueryParams(): array
148149
{
149150
return [
150151
[
151-
"name" => "__limit",
152+
"name" => Api::API_LIMIT_FIELD,
152153
"in" => "query",
153154
"description" => t("Record limit to return, -1 to return all records"),
154155
"required" => false,
155156
"type" => "integer",
156157
],
157158
[
158-
"name" => "__page",
159+
"name" => Api::API_PAGE_FIELD,
159160
"in" => "query",
160161
"description" => t("Page to return"),
161162
"required" => false,
162163
"type" => "integer",
163164
],
164165
[
165-
"name" => "__fields",
166+
"name" => Api::API_FIELDS_RESULT_FIELD,
166167
"in" => "query",
167168
"description" => t("Fields to return"),
168169
"required" => false,

src/base/types/traits/Api/Crud/ApiListTrait.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Propel\Runtime\ActiveQuery\ModelCriteria;
66
use PSFS\base\dto\Order;
77
use PSFS\base\Logger;
8+
use PSFS\base\types\Api;
89
use PSFS\base\types\helpers\ApiHelper;
910
use PSFS\base\types\helpers\attributes\Injectable;
1011
use PSFS\base\types\traits\Api\MutationTrait;
@@ -139,22 +140,22 @@ protected function paginate()
139140

140141
private function apiComboField(): string
141142
{
142-
return '__combo';
143+
return Api::API_COMBO_FIELD;
143144
}
144145

145146
private function apiOrderField(): string
146147
{
147-
return '__order';
148+
return Api::API_ORDER_FIELD;
148149
}
149150

150151
private function apiPageField(): string
151152
{
152-
return '__page';
153+
return Api::API_PAGE_FIELD;
153154
}
154155

155156
private function apiLimitField(): string
156157
{
157-
return '__limit';
158+
return Api::API_LIMIT_FIELD;
158159
}
159160

160161
}

0 commit comments

Comments
 (0)