samrap/acf-fluent

Support for "macros"

samrap opened this issue · 0 comments

The ability to define something like this...

Acf::macro('imageArray', function ($builder) {
    return $builder
        ->expect('array')
        ->default([
            'url' => 'default.jpg',
            'alt' => 'Default Image',
        ]);
});

...and then call that "macro" from anywhere else in your code...

Acf::field('image')->imageArray()->get();

...might be a good way to shorten complex ACF queries especially when using the same expectation logic throughout templates.