function olivero_theme_suggestions_block_alter in Drupal 9
Implements hook_theme_suggestions_HOOK_alter() for block().
File
- core/
themes/ olivero/ olivero.theme, line 214 - 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'];
}
}
}