function BlockContentThemeSuggestionsTestThemeHooks::preprocessBlock

Same name and namespace in other branches
  1. 11.x core/modules/block_content/tests/modules/block_content_theme_suggestions_test/src/Hook/BlockContentThemeSuggestionsTestThemeHooks.php \Drupal\block_content_theme_suggestions_test\Hook\BlockContentThemeSuggestionsTestThemeHooks::preprocessBlock()

Implements hook_preprocess_block().

Attributes

#[Hook('preprocess_block')]

File

core/modules/block_content/tests/modules/block_content_theme_suggestions_test/src/Hook/BlockContentThemeSuggestionsTestThemeHooks.php, line 18

Class

BlockContentThemeSuggestionsTestThemeHooks
Hook implementations for block_content_theme_suggestions_test.

Namespace

Drupal\block_content_theme_suggestions_test\Hook

Code

public function preprocessBlock(&$variables) : void {
  $block_content = $variables['elements']['content']['#block_content'] ?? NULL;
  if ($block_content instanceof BlockContentInterface) {
    $variables['label'] = $block_content->label();
  }
}

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