function Stable9Hooks::preprocessBlock

Same name and namespace in other branches
  1. 11.x core/themes/stable9/src/Hook/Stable9Hooks.php \Drupal\stable9\Hook\Stable9Hooks::preprocessBlock()

Implements hook_preprocess_block().

Copies block content attributes to the block wrapper for backward compatibility.

Attributes

#[Hook('preprocess_block')]

File

core/themes/stable9/src/Hook/Stable9Hooks.php, line 23

Class

Stable9Hooks
Hook implementations for stable9.

Namespace

Drupal\stable9\Hook

Code

public function preprocessBlock(&$variables) : void {
  if (isset($variables['content']['#attributes'])) {
    if (isset($variables['attributes'])) {
      $variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], $variables['content']['#attributes']);
    }
    else {
      $variables['attributes'] = $variables['content']['#attributes'];
    }
    unset($variables['content']['#attributes']);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.