[TASK] Improve result handling for apis

This commit is contained in:
Philipp Dieter 2021-11-05 14:23:39 +01:00
parent f427ab7cd6
commit cf387b1af7
2 changed files with 18 additions and 4 deletions

View File

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

View File

@ -21,8 +21,7 @@ trait FormatResultTrait
/** /**
* *
*/ */
public function formatResult() public function formatResult($result) {
{
if ($result == null) { if ($result == null) {
$result = []; $result = [];
} }