Updated latest changes
This commit is contained in:
parent
752c6b4ecb
commit
50d404e7a3
3 changed files with 11 additions and 12 deletions
|
@ -184,7 +184,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
||||||
Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys.
|
Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys.
|
||||||
}
|
}
|
||||||
|
|
||||||
if($user->getId()) {
|
if ($user->getId()) {
|
||||||
Authorization::setRole('user:'.$user->getId());
|
Authorization::setRole('user:'.$user->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,28 +230,27 @@ class Response extends SwooleResponse
|
||||||
$model = $this->getModel($model);
|
$model = $this->getModel($model);
|
||||||
$output = [];
|
$output = [];
|
||||||
|
|
||||||
if($model->isAny()) {
|
if ($model->isAny()) {
|
||||||
return $document->getArrayCopy();
|
return $document->getArrayCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($model->getRules() as $key => $rule) {
|
foreach ($model->getRules() as $key => $rule) {
|
||||||
if(!$document->isSet($key)) {
|
if (!$document->isSet($key)) {
|
||||||
if(!is_null($rule['default'])) {
|
if (!is_null($rule['default'])) {
|
||||||
$document->setAttribute($key, $rule['default']);
|
$document->setAttribute($key, $rule['default']);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw new Exception('Model '.$model->getName().' is missing response key: '.$key);
|
throw new Exception('Model '.$model->getName().' is missing response key: '.$key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($rule['array']) {
|
if ($rule['array']) {
|
||||||
if(!is_array($data[$key])) {
|
if (!is_array($data[$key])) {
|
||||||
throw new Exception($key.' must be an array of type '.$rule['type']);
|
throw new Exception($key.' must be an array of type '.$rule['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data[$key] as &$item) {
|
foreach ($data[$key] as &$item) {
|
||||||
if($item instanceof Document) {
|
if ($item instanceof Document) {
|
||||||
if(!array_key_exists($rule['type'], $this->models)) {
|
if (!array_key_exists($rule['type'], $this->models)) {
|
||||||
throw new Exception('Missing model for rule: '. $rule['type']);
|
throw new Exception('Missing model for rule: '. $rule['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class BaseList extends Model
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
if($paging) {
|
if ($paging) {
|
||||||
$this->addRule('sum', [
|
$this->addRule('sum', [
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => 'Total sum of items in the list.',
|
'description' => 'Total sum of items in the list.',
|
||||||
|
|
Loading…
Reference in a new issue