From f53b2f13847557fcc9a75f9b72ef3477626e69ea Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 15 Dec 2020 18:30:16 +0300 Subject: [PATCH] feat(fields): Add new field `entries.fetchSingle` and `entries.fetchCollection` for Entries API #492 --- src/flextype/Foundation/Entries/Fields/EntriesField.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/flextype/Foundation/Entries/Fields/EntriesField.php b/src/flextype/Foundation/Entries/Fields/EntriesField.php index e995888a..9b6e1804 100644 --- a/src/flextype/Foundation/Entries/Fields/EntriesField.php +++ b/src/flextype/Foundation/Entries/Fields/EntriesField.php @@ -26,10 +26,11 @@ if (flextype('registry')->get('flextype.settings.entries.fields.entries.fetchCol // Modify fetch. foreach (flextype('entries')->getStorage('fetch.data.entries.fetchCollection') as $field => $body) { + $result = isset($body['result']) && in_array($body['result'], ['toArray', 'toObject']) ? $body['result'] : $resultTo; $data[$field] = flextype('entries')->fetchCollection($body['id'], isset($body['options']) ? $body['options'] : - [])->{$resultTo}(); + [])->{$result}(); } // Save fetch. @@ -59,10 +60,11 @@ if (flextype('registry')->get('flextype.settings.entries.fields.entries.fetchSin // Modify fetch. foreach (flextype('entries')->getStorage('fetch.data.entries.fetchSingle') as $field => $body) { + $result = isset($body['result']) && in_array($body['result'], ['toArray', 'toObject']) ? $body['result'] : $resultTo; $data[$field] = flextype('entries')->fetchSingle($body['id'], isset($body['options']) ? $body['options'] : - [])->{$resultTo}(); + [])->{$result}(); } // Save fetch.