30 lines
896 B
PHP
30 lines
896 B
PHP
<?php
|
|
/**
|
|
* @file
|
|
* Block-related functions.
|
|
*/
|
|
|
|
use Drupal\block\Entity\Block;
|
|
|
|
/**
|
|
* Implements hook_preprocess_block().
|
|
* http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
|
|
*/
|
|
function cdesai_emulsify_preprocess_block(&$variables) {
|
|
if(isset($variables['attributes']['id'])) {
|
|
$variables['content']['#attributes']['block'] = $variables['attributes']['id'];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements hook_theme_suggestions_HOOK_alter().
|
|
*/
|
|
function cdesai_emulsify_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
|
|
// Remove the block and replace dashes with underscores in the block ID to
|
|
// use for the hook name.
|
|
if (isset($variables['attributes']['block'])) {
|
|
$hook = str_replace(array('block-', '-'), array('', '_'), $variables['attributes']['block']);
|
|
$suggestions[] = $variables['theme_hook_original'] . '__' . $hook;
|
|
}
|
|
}
|