Not getting any result by doing hook_block_view_NAME_alter() as in BlockRenderController->viewMultiple the name is being retrieved from the entity like this

list(, $name) = $entity->id();

But id is a string, i.e. bartik.content and that would result in hook_block_view_bartik.content_alter, a simple explode is needed here

list(, $name) = explode('.', $entity->id());

Comments

pcambra’s picture

Issue tags: +Needs tests
StatusFileSize
new748 bytes
pcambra’s picture

For the tests, the best thing here is to create a new hidden module for testing that provides a block in configuration and alter it using the 3 available hooks.

larowlan’s picture

Assigned: Unassigned » larowlan

Will handle tests

larowlan’s picture

Assigned: larowlan » Unassigned

Sorry for squating on this

pcambra’s picture

Status: Active » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.58 KB

Here's the fix with a little test module and some assertions.

I've found a naming problem though, $id and $name properties are really confusing, I've opened #1948928: ID and NAME are confusing in block_alter hooks for fixing that.

benjy’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
pcambra’s picture

Status: Needs work » Needs review

Patch applies cleanly Checked it badly.

Still, based in some chat with EclipseGc back then I dunno if it's needed anymore though

pcambra’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll, -Blocks-Layouts, -Plugin system, -Block plugins

Status: Needs review » Needs work
Issue tags: +Needs reroll, +Blocks-Layouts, +Plugin system, +Block plugins

The last submitted patch, 1899772-block_plugin_name_retrieve_fix-5.patch, failed testing.

pcambra’s picture

Status: Needs review » Closed (works as designed)

Marking this as closed, "outdated" I guess, this code has changed enormously since March and this has been fixed already.