You are here

function olivero_theme_suggestions_block_alter in Drupal 10

Same name and namespace in other branches
  1. 9 core/themes/olivero/olivero.theme \olivero_theme_suggestions_block_alter()

Implements hook_theme_suggestions_HOOK_alter() for block().

File

core/themes/olivero/olivero.theme, line 220
Functions to support theming in the Olivero theme.

Code

function olivero_theme_suggestions_block_alter(&$suggestions, array $variables) {
  if (!empty($variables['elements']['#id'])) {

    /** @var \Drupal\block\BlockInterface $block */
    $block = \Drupal::entityTypeManager()
      ->getStorage('block')
      ->load($variables['elements']['#id']);
    if ($block) {

      // Add region-specific block theme suggestions.
      $region = $block
        ->getRegion();
      $suggestions[] = 'block__' . $region;
      $suggestions[] = 'block__' . $region . '__' . 'plugin_id' . '__' . $variables['elements']['#plugin_id'];
      $suggestions[] = 'block__' . $region . '__' . 'id' . '__' . $variables['elements']['#id'];
    }
  }
}