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
419 stars 57 forks source link

Block::getTemplate() fails on innerBlock #212

Closed dsturm closed 7 months ago

dsturm commented 7 months ago

Since #209 Block::getTemplate() returns a JSON / string. Hence the map() callback in https://github.com/Log1x/acf-composer/blob/a49708259ae1228f70e247d937c70f5d1e95c37c/src/Block.php#L339-L341 will fail at calling ->all() on a string.

I'm currently not sure, whether we need the ->all() in the callback.

Log1x commented 7 months ago

Yeah I think the method will have to be split or the logic changed slightly. In the current form, that map needs to be returning as an array.

Log1x commented 7 months ago

Re-reading 209 again, I'm slightly confused by the initial issue. $template doesn't get cached. Is this happening from partials?

dsturm commented 7 months ago

Unfortunately, I had not tested the issue mentioned by @djaevlen. As a quickfix, if I ditch the ->all() in the callback, it works. But I'm not sure, whether all possible template data of a block would convert correctly.

Log1x commented 7 months ago

i should have a fix in a few minutes

djaevlen commented 7 months ago

Re-reading 209 again, I'm slightly confused by the initial issue. $template doesn't get cached. Is this happening from partials?

In my issue the block (acf/button) that mainly have the template issue is using a addPartial.

/**
     * The block field group.
     *
     * @return array
     */
    public function fields()
    {
        $button = Builder::make('button');

        $button->addPartial(ButtonPartial::class);

        return $button->build();
    }
Log1x commented 7 months ago

The block (acf/button) that mainly have the issue is using a addPartial.

let me know if this still happens on .10