[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(
$result = []
) {
$result = $this->formatResult($result);
$result = $this->formatResult($result, 'asd');
unset($result['cid']);
unset($result['componentMode']);
unset($result['isValid']);
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) {
$result = [];
}