Closed (fixed)
Project:
Context
Version:
8.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
22 Feb 2019 at 18:41 UTC
Updated:
29 Apr 2020 at 18:54 UTC
Jump to comment: Most recent
In Drupal\context\Plugin\ContextReaction\Blocks:execute() this code is used to build the block and add it's contextual links to the block #theme element render array.
// Add contextual links to block.
$content = $block->build();
if (isset($content['#contextual_links'])) {
$blockBuild['#contextual_links'] = $content['#contextual_links'];
}
I don't quite understand the need for this as it is now invoking the block->build() twice while ::preRenderBlock actually renders the block.
I don't see this double-build issue in any other modules ex:
Drupal\block\BlockViewBuilder::buildPreRenderableBlock
Drupal\ds\Plugin\DsField\BlockBase::build
Remove the $block->build() from Drupal\context\Plugin\ContextReaction\Blocks:execute().
| Comment | File | Size | Author |
|---|---|---|---|
| context-block-build-twice.patch | 737 bytes | malcolm_p |
Comments
Comment #2
nace_fr commentedI have reviewed this and it works. I'm moving this to "Reviewed".
Comment #4
boshtian commented