|
@@ -3264,12 +3264,16 @@ class IpAddressMiddleware extends Middleware
|
3264
|
3264
|
private function callHandler($record, String $operation, ReflectedTable $table) /*: object */
|
3265
|
3265
|
{
|
3266
|
3266
|
$context = (array) $record;
|
3267
|
|
- $columnName = $this->getProperty('column', '');
|
3268
|
|
- if ($table->hasColumn($columnName)) {
|
3269
|
|
- if ($operation == 'create') {
|
3270
|
|
- $context[$columnName] = $_SERVER['REMOTE_ADDR'];
|
3271
|
|
- } else {
|
3272
|
|
- unset($context[$columnName]);
|
|
3267
|
+ $columnNames = $this->getProperty('columns', '');
|
|
3268
|
+ if ($columnNames) {
|
|
3269
|
+ foreach (explode(',', $columnNames) as $columnName) {
|
|
3270
|
+ if ($table->hasColumn($columnName)) {
|
|
3271
|
+ if ($operation == 'create') {
|
|
3272
|
+ $context[$columnName] = $_SERVER['REMOTE_ADDR'];
|
|
3273
|
+ } else {
|
|
3274
|
+ unset($context[$columnName]);
|
|
3275
|
+ }
|
|
3276
|
+ }
|
3273
|
3277
|
}
|
3274
|
3278
|
}
|
3275
|
3279
|
return (object) $context;
|
|
@@ -3279,19 +3283,22 @@ class IpAddressMiddleware extends Middleware
|
3279
|
3283
|
{
|
3280
|
3284
|
$operation = $this->utils->getOperation($request);
|
3281
|
3285
|
if (in_array($operation, ['create', 'update', 'increment'])) {
|
|
3286
|
+ $tableNames = $this->getProperty('tables', '');
|
3282
|
3287
|
$tableName = $request->getPathSegment(2);
|
3283
|
|
- if ($this->reflection->hasTable($tableName)) {
|
3284
|
|
- $record = $request->getBody();
|
3285
|
|
- if ($record !== null) {
|
3286
|
|
- $table = $this->reflection->getTable($tableName);
|
3287
|
|
- if (is_array($record)) {
|
3288
|
|
- foreach ($record as &$r) {
|
3289
|
|
- $r = $this->callHandler($r, $operation, $table);
|
|
3288
|
+ if (!$tableNames || in_array($tableName, explode(',', $tableNames))) {
|
|
3289
|
+ if ($this->reflection->hasTable($tableName)) {
|
|
3290
|
+ $record = $request->getBody();
|
|
3291
|
+ if ($record !== null) {
|
|
3292
|
+ $table = $this->reflection->getTable($tableName);
|
|
3293
|
+ if (is_array($record)) {
|
|
3294
|
+ foreach ($record as &$r) {
|
|
3295
|
+ $r = $this->callHandler($r, $operation, $table);
|
|
3296
|
+ }
|
|
3297
|
+ } else {
|
|
3298
|
+ $record = $this->callHandler($record, $operation, $table);
|
3290
|
3299
|
}
|
3291
|
|
- } else {
|
3292
|
|
- $record = $this->callHandler($record, $operation, $table);
|
|
3300
|
+ $request->setBody($record);
|
3293
|
3301
|
}
|
3294
|
|
- $request->setBody($record);
|
3295
|
3302
|
}
|
3296
|
3303
|
}
|
3297
|
3304
|
}
|
|
@@ -3958,6 +3965,13 @@ class OpenApiBuilder
|
3958
|
3965
|
foreach ($properties as $key => $value) {
|
3959
|
3966
|
$this->openapi->set("$prefix|properties|$columnName|$key", $value);
|
3960
|
3967
|
}
|
|
3968
|
+ if ($column->getPk()) {
|
|
3969
|
+ $this->openapi->set("$prefix|properties|$columnName|x-primary-key", true);
|
|
3970
|
+ }
|
|
3971
|
+ $fk = $column->getFk();
|
|
3972
|
+ if ($fk) {
|
|
3973
|
+ $this->openapi->set("$prefix|properties|$columnName|x-references", $fk);
|
|
3974
|
+ }
|
3961
|
3975
|
}
|
3962
|
3976
|
}
|
3963
|
3977
|
}
|