1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

feat(fields): Add new field entries.fetch for Entries API #492

This commit is contained in:
Awilum
2020-12-17 12:26:32 +03:00
parent 5b709ba227
commit 12d43ed401

View File

@@ -29,13 +29,14 @@ declare(strict_types=1);
foreach (flextype('entries')->getStorage('fetch.data.entries.fetch') as $field => $body) {
if (isset($body['method']) &&
str_contains($body['method'], 'fetch') &&
strpos($body['method'], 'fetch') !== false &&
is_callable([flextype('entries'), $body['method']])) {
$fetchFromCallbackMethod = $body['method'];
} else {
$fetchFromCallbackMethod = 'fetch';
}
$result = isset($body['result']) && in_array($body['result'], ['toArray', 'toObject']) ? $body['result'] : $resultTo;
$data[$field] = flextype('entries')->{$fetchFromCallbackMethod}($body['id'],