function UmamiHooks::preprocessBlock

Same name and namespace in other branches
  1. 11.x core/profiles/demo_umami/themes/umami/src/Hook/UmamiHooks.php \Drupal\umami\Hook\UmamiHooks::preprocessBlock()

Implements hook_preprocess_HOOK() for block.

Attributes

#[Hook('preprocess_block')]

File

core/profiles/demo_umami/themes/umami/src/Hook/UmamiHooks.php, line 57

Class

UmamiHooks
Hook implementations for umami.

Namespace

Drupal\umami\Hook

Code

public function preprocessBlock(&$variables) : void {
  $variables['title_attributes']['class'][] = 'block__title';
  // Add a class indicating the content block bundle.
  if (isset($variables['elements']['content']['#block_content'])) {
    $variables['attributes']['class'][] = Html::getClass('block-type-' . $variables['elements']['content']['#block_content']->bundle());
  }
}

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