1
0
Fork 0
mirror of synced 2024-06-20 19:50:30 +12:00

Updated latest changes

This commit is contained in:
Eldad Fux 2020-10-30 00:44:01 +02:00
parent 752c6b4ecb
commit 50d404e7a3
3 changed files with 11 additions and 12 deletions

View file

@ -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());
}

View file

@ -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']);
}

View file

@ -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.',