Skip to content

Commit c2f16b1

Browse files
committed
Can only POST/PUT exposed columns
1 parent 0a9878e commit c2f16b1

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
### 2.0.2
4+
5+
Fixed: Can only POST/PUT exposed columns
6+
37
### 2.0.1
48

59
Added: IpRestrictedAuthenticationProvider

src/Resources/ModelRestResource.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ protected function getSummaryColumns()
215215
}
216216

217217
/**
218-
* Override to control the columns returned in GET requests
218+
* Override to control the columns exposed by the rest resource (output in GET requests, accepted via PUT/POST)
219219
*
220220
* @return string[]
221221
*/
@@ -347,7 +347,7 @@ public function put($restResource)
347347
{
348348
try {
349349
$model = $this->getModel();
350-
$model->importData($restResource);
350+
$this->importModelData($model, $restResource);
351351

352352
$this->beforeModelUpdated($model, $restResource);
353353

@@ -613,7 +613,7 @@ public function post($restResource)
613613
$newModel = SolutionSchema::getModel($this->getModelName());
614614

615615
if (is_array($restResource)) {
616-
$newModel->importData($restResource);
616+
$this->importModelData($newModel, $restResource);
617617
}
618618
$this->beforeModelCreated($newModel, $restResource);
619619

@@ -653,6 +653,15 @@ protected function beforeModelCreated($model, $restResource)
653653

654654
}
655655

656+
/**
657+
* @param Model $model
658+
* @param array $modelData
659+
*/
660+
protected function importModelData($model, $modelData)
661+
{
662+
$model->importData(array_intersect_key($modelData, array_flip($this->getColumns())));
663+
}
664+
656665
/**
657666
* Returns the ItemRestResource for the $resourceIdentifier contained in this collection.
658667
*

0 commit comments

Comments
 (0)