From 50d404e7a375f7e93cf0a5dacd7d9fb7466b7035 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Fri, 30 Oct 2020 00:44:01 +0200 Subject: [PATCH] Updated latest changes --- app/controllers/general.php | 2 +- src/Appwrite/Utopia/Response.php | 19 +++++++++---------- .../Utopia/Response/Model/BaseList.php | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 864aa6bd5..94926a936 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -184,7 +184,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys. } - if($user->getId()) { + if ($user->getId()) { Authorization::setRole('user:'.$user->getId()); } diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 017e49940..22f2925e5 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -230,28 +230,27 @@ class Response extends SwooleResponse $model = $this->getModel($model); $output = []; - if($model->isAny()) { + if ($model->isAny()) { return $document->getArrayCopy(); } - foreach($model->getRules() as $key => $rule) { - if(!$document->isSet($key)) { - if(!is_null($rule['default'])) { + foreach ($model->getRules() as $key => $rule) { + if (!$document->isSet($key)) { + if (!is_null($rule['default'])) { $document->setAttribute($key, $rule['default']); - } - else { + } else { throw new Exception('Model '.$model->getName().' is missing response key: '.$key); } } - if($rule['array']) { - if(!is_array($data[$key])) { + if ($rule['array']) { + if (!is_array($data[$key])) { throw new Exception($key.' must be an array of type '.$rule['type']); } foreach ($data[$key] as &$item) { - if($item instanceof Document) { - if(!array_key_exists($rule['type'], $this->models)) { + if ($item instanceof Document) { + if (!array_key_exists($rule['type'], $this->models)) { throw new Exception('Missing model for rule: '. $rule['type']); } diff --git a/src/Appwrite/Utopia/Response/Model/BaseList.php b/src/Appwrite/Utopia/Response/Model/BaseList.php index 2f30b1838..21dd6eb92 100644 --- a/src/Appwrite/Utopia/Response/Model/BaseList.php +++ b/src/Appwrite/Utopia/Response/Model/BaseList.php @@ -22,7 +22,7 @@ class BaseList extends Model $this->name = $name; $this->type = $type; - if($paging) { + if ($paging) { $this->addRule('sum', [ 'type' => 'integer', 'description' => 'Total sum of items in the list.',