Skip to content

Commit

Permalink
StyleCI patch
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhenry committed Aug 20, 2015
1 parent 4d4bd64 commit 8c1daaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 4 additions & 5 deletions api/app/Extensions/Controller/RequestValidationTrait.php
Expand Up @@ -155,19 +155,18 @@ public function validateRequestCollection($requestCollection, $validationRules,
protected function checkEntityIdMatchesRoute(Request $request, $id, BaseModel $model, $requireEntityKey = true)
{
$keyName = $model->getKeyName();
if (!$request->has($keyName)){
if (!$requireEntityKey){
if (!$request->has($keyName)) {
if (!$requireEntityKey) {
return true; //it is ok if the key is not set (for patch requests etc)
}else{
} else {
throw new BadRequestException("Request entity must include entity id ($keyName) for ".get_class($model));
}
}

if ($request->input($keyName) !== $id){
if ($request->input($keyName) !== $id) {
throw new BadRequestException("Provided entity body does not match route parameter. The entity key cannot be updated");
}

return true;
}

}
1 change: 0 additions & 1 deletion api/app/Http/Controllers/ChildEntityController.php
Expand Up @@ -124,7 +124,6 @@ public function postOne(Request $request, $id)
*/
public function putOne(Request $request, $id, $childId)
{

$parent = $this->findParentEntity($id);

$this->checkEntityIdMatchesRoute($request, $childId, $this->getChildModel());
Expand Down

0 comments on commit 8c1daaa

Please sign in to comment.