[TASK] Improve result handling for apis
This commit is contained in:
parent
f427ab7cd6
commit
cf387b1af7
@ -266,11 +266,26 @@ class AbstractEIDController
|
|||||||
protected function returnFunction(
|
protected function returnFunction(
|
||||||
$result = []
|
$result = []
|
||||||
) {
|
) {
|
||||||
$result = $this->formatResult($result);
|
$result = $this->formatResult($result, 'asd');
|
||||||
unset($result['cid']);
|
unset($result['cid']);
|
||||||
unset($result['componentMode']);
|
unset($result['componentMode']);
|
||||||
unset($result['isValid']);
|
unset($result['isValid']);
|
||||||
return $result;
|
if ($result) {
|
||||||
|
if (!empty($this->errors)) {
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
'metadata' => [
|
||||||
|
'total' => count($result),
|
||||||
|
'count' => count($result),
|
||||||
|
],
|
||||||
|
'result' => $result,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
//return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,7 @@ trait FormatResultTrait
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function formatResult()
|
public function formatResult($result) {
|
||||||
{
|
|
||||||
if ($result == null) {
|
if ($result == null) {
|
||||||
$result = [];
|
$result = [];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user