From 3a89f98ac8bd6112e1e6740635a29e9e9c528c75 Mon Sep 17 00:00:00 2001 From: stuartcusackie Date: Thu, 20 Jan 2022 10:43:19 +0000 Subject: [PATCH] Add Entry Augmentor and helper. --- src/Augmentation/AugmentedEntry.php | 17 +++++++++++++++++ src/helpers.php | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/Augmentation/AugmentedEntry.php diff --git a/src/Augmentation/AugmentedEntry.php b/src/Augmentation/AugmentedEntry.php new file mode 100644 index 0000000..4ed0579 --- /dev/null +++ b/src/Augmentation/AugmentedEntry.php @@ -0,0 +1,17 @@ +getAugmentedValue($data); + }, $entry->toAugmentedArray()); + } +} diff --git a/src/helpers.php b/src/helpers.php index bdbd8f6..4113180 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -4,6 +4,8 @@ use Statamic\Modifiers\Modify; use Statamic\Tags\Loader as TagLoader; use Statamic\View\Antlers\Parser; +use Statamic\Entries\Entry; +use Edalzell\Blade\Augmentation\AugmentedEntry; if (! function_exists('modify')) { /** @@ -49,3 +51,17 @@ function tag(string $name, array $params = [], array $context = []) return $tag->$method(); } } + +if(! function_exists('augment_entry')) { + /** + * Augment an entire entry to an array. + * + * @param \Statamic\Entries\Entry $entry + * @return array + */ + function augment_entry(Entry $entry): array + { + $augmentor = new AugmentedEntry(); + return $augmentor->gatherEntryData($entry); + } +} \ No newline at end of file