Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
Add Entry Augmentor and helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcusackie authored and edalzell committed Mar 19, 2022
1 parent 7629945 commit 3a89f98
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Augmentation/AugmentedEntry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Edalzell\Blade\Augmentation;

use Edalzell\Blade\Concerns\AugmentsValues;

class AugmentedEntry
{
use AugmentsValues;

public function gatherEntryData($entry): array
{
return array_map(function ($data) {
return $this->getAugmentedValue($data);
}, $entry->toAugmentedArray());
}
}
16 changes: 16 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
/**
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 3a89f98

Please sign in to comment.