Problem
The block field module doesn't quite utilise the BlockViewBuilder which is unfortunate because it means we miss some crucial Drupal hooks.
Solution
I tried to use the BlockViewBuilder but I wasn't able to reliably get the entity that should be rendered (I don't know if the block_field module actually creates it). For example if you use a view as a block in block_field then you can't find this in the viewElements method of the BlockFieldFormatter class.
Therefor I've just added the two alter hooks that are in the view builder in the viewElements method.
Work left
One of the things that still needs to happen is to use dependency injection in the field formatter. However, this was an existing problem so I suggest creating a follow-up issue to fix this.
Comments
Comment #2
kingdutchComment #3
cameron prince commentedComment #4
nickdickinsonwildeNeeded a re-roll and I didn't see this issue in the backscroll... so I did just the view hooks. Then merged in the build hooks. So patch attached that works with latest dev.
Does move to proper dependency injection which is an expansion of scope, but didn't want to add anything without adding that.
Comment #5
nickdickinsonwildeRerolled...
Comment #6
paulocsLooks good to me.
Good work!
Comment #8
paulocsThanks!