You are here

function component_blocks_theme_suggestions_block_alter in Component blocks 1.1.x

Same name and namespace in other branches
  1. 1.x component_blocks.module \component_blocks_theme_suggestions_block_alter()
  2. 1.0.x component_blocks.module \component_blocks_theme_suggestions_block_alter()

Implements theme_suggestions_HOOK_alter().

File

./component_blocks.module, line 25
Contains main module functions.

Code

function component_blocks_theme_suggestions_block_alter(&$hooks, &$vars) {
  if ($storage = \Drupal::routeMatch()
    ->getParameter('section_storage')) {

    // This is layout builder.
    return;
  }
  if (isset($vars['elements']['#base_plugin_id']) && $vars['elements']['#base_plugin_id'] === 'component_blocks') {
    $hooks[] = 'block__bare';
    if (!empty($vars['elements']['#attributes'])) {
      if (!empty($vars['elements']['content']['#attributes'])) {

        // Push the wrapper attributes down to the content.
        $vars['elements']['content']['#attributes'] = NestedArray::mergeDeep($vars['content']['#attributes'], $vars['elements']['#attributes']);
        return;
      }
      if (is_array($vars['elements']['content'])) {
        $vars['elements']['content']['#attributes'] = $vars['elements']['#attributes'];
      }
    }
  }
}