record collection getApiOutput method

This commit is contained in:
Yuri Kuznetsov
2025-04-15 09:45:46 +03:00
parent 963fb40b2b
commit 4559f2746e
15 changed files with 52 additions and 81 deletions
+4 -4
View File
@@ -35,6 +35,9 @@ use Espo\Tools\ActionHistory\Service as Service;
use stdClass;
/**
* @noinspection PhpUnused
*/
class LastViewed
{
public function __construct(private SearchParamsFetcher $searchParamsFetcher, private Service $service)
@@ -49,9 +52,6 @@ class LastViewed
$result = $this->service->getLastViewed($maxSize, $offset);
return (object) [
'total' => $result->getTotal(),
'list' => $result->getValueMapList(),
];
return $result->toApiOutput();
}
}
@@ -83,10 +83,7 @@ class Notification extends RecordBase
$recordCollection = $this->getNotificationService()->get($userId, $searchParams);
return (object) [
'total' => $recordCollection->getTotal(),
'list' => $recordCollection->getValueMapList(),
];
return $recordCollection->toApiOutput();
}
public function getActionNotReadCount(): int
+13 -19
View File
@@ -79,12 +79,12 @@ class Stream
$reactionsCheckDate = DateTime::createNow();
return (object) [
'total' => $collection->getTotal(),
'list' => $collection->getValueMapList(),
'reactionsCheckDate' => $reactionsCheckDate->toString(),
'updatedReactions' => $this->getReactionUpdates($request, $id),
];
$output = $collection->toApiOutput();
$output->reactionsCheckDate = $reactionsCheckDate->toString();
$output->updatedReactions = $this->getReactionUpdates($request, $id);
return $output;
}
if ($id === null) {
@@ -94,11 +94,11 @@ class Stream
$collection = $this->service->find($scope, $id, $searchParams);
$pinnedCollection = $this->service->getPinned($scope, $id);
return (object) [
'total' => $collection->getTotal(),
'list' => $collection->getValueMapList(),
'pinnedList' => $pinnedCollection->getValueMapList(),
];
$output = $collection->toApiOutput();
$output->pinnedList = $pinnedCollection->getValueMapList();
return $output;
}
/**
@@ -126,10 +126,7 @@ class Stream
$this->userRecordService->find($id, $searchParams) :
$this->service->find($scope, $id ?? '', $searchParams);
return (object) [
'total' => $result->getTotal(),
'list' => $result->getValueMapList(),
];
return $result->toApiOutput();
}
/**
@@ -150,10 +147,7 @@ class Stream
$result = $this->service->findUpdates($scope, $id, $searchParams);
return (object) [
'total' => $result->getTotal(),
'list' => $result->getValueMapList(),
];
return $result->toApiOutput();
}
/**