Closed responsemktg closed 1 year ago
Not at the moment but I'm not opposed to implementing it at some point.
@Log1x I took a look through the src, and I see I could do something like this:
Add some custom paths into config > view.php:
'paths' => [
get_theme_file_path('/My/Blocks'),
get_parent_theme_file_path('/My/Blocks'),
get_theme_file_path('/resources/views'),
get_parent_theme_file_path('/resources/views'),
],
And then glob the directory of blocks to register their paths:
$app = new AcfComposer(app());
$dirs = glob(get_theme_file_path('/My/Blocks/*'), GLOB_ONLYDIR);
foreach ($dirs as $d) {
$name = basename($d);
$class = "My\\Blocks\\" . $name . '\\';
$p = $app->registerPath($d, $class);
}
Which is cool, and then I just need to add the block view into the block.php:
/**
* The block view.
*
* @var string
*/
public $view = 'TestBlock.view';
Badda Bing, Badda Boom. Cheers!
🔥
I know with the composers , you could set a config option that would be loaded by $this->app->config['view.composers'] by doing something similar to this:
Is there the equivalent of this for acf-composer blocks?