Commit a4f5a824 authored by git's avatar git Committed by boshtian

Issue #2979536 by George Bills: Context overwrites block #attributes

parent c9d12454
......@@ -219,9 +219,6 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
// @see template_preprocess_block().
$blockBuild = [
'#theme' => 'block',
'#attributes' => [
'class' => [$configuration['css_class']]
],
'#configuration' => $configuration,
'#plugin_id' => $block->getPluginId(),
'#base_plugin_id' => $block->getBaseId(),
......@@ -242,6 +239,12 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
],
];
// Merge existing attributes from block with class(es) configured in Context.
$block_content = $block->build();
$existing_attributes = isset($block_content['#attributes']) ? $block_content['#attributes'] : [];
$new_attributes['class'][] = $configuration['css_class'];
$block_build['#attributes'] = array_merge_recursive($existing_attributes, $new_attributes);
// Add additional contextual link, for editing block configuration.
$blockBuild['#contextual_links']['context_block'] = [
'route_parameters' => [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment