Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
413 stars 56 forks source link

Allow for non-static example data #152

Closed broskees closed 1 year ago

Log1x commented 1 year ago

Thanks for the PR. Not against this whatsoever, but could you provide a use-case/example for needing this?

broskees commented 1 year ago

@Log1x Sure. The use case I ran into was I wanted a default image url from my theme and wanted to use the public_path() function to resolve it. I could not do this though because the example variable is static.

Basically any time you want to use a method/function call in the example data, you would need to use the example() method.

broskees commented 1 year ago

@Log1x Anything else I can do to get this merged? Found myself needing it again today.

dashw00d commented 1 year ago

You could always do:

...
use Roots\Acorn\Application;
...

public function __construct(Application $app)
{
    $this->example = $this->example();

    parent::__construct($app);
}