Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block::getTemplate() fails on innerBlock #212

Closed
dsturm opened this issue Feb 29, 2024 · 6 comments
Closed

Block::getTemplate() fails on innerBlock #212

dsturm opened this issue Feb 29, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@dsturm
Copy link
Contributor

dsturm commented Feb 29, 2024

Since #209 Block::getTemplate() returns a JSON / string. Hence the map() callback in

acf-composer/src/Block.php

Lines 339 to 341 in a497082

$innerBlocks = collect($value['innerBlocks'])->map(function ($innerBlock) {
return $this->getTemplate($innerBlock)->all();
})->collapse();
will fail at calling ->all() on a string.

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

@Log1x Log1x added the bug Something isn't working label Feb 29, 2024
@Log1x
Copy link
Owner

Log1x commented Feb 29, 2024

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
Copy link
Owner

Log1x commented Feb 29, 2024

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

@dsturm
Copy link
Contributor Author

dsturm commented Feb 29, 2024

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
Copy link
Owner

Log1x commented Feb 29, 2024

i should have a fix in a few minutes

@djaevlen
Copy link
Contributor

djaevlen commented Feb 29, 2024

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
Copy link
Owner

Log1x commented Feb 29, 2024

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

let me know if this still happens on .10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants