function template_preprocess_tb_megamenu_block in The Better Mega Menu 8
Same name and namespace in other branches
- 7 tb_megamenu.themes.inc \template_preprocess_tb_megamenu_block()
- 2.x tb_megamenu.module \template_preprocess_tb_megamenu_block()
Prepare variables for tb_megamenu_block.
Parameters
array $vars: Variables are declared in theme.
File
- ./
tb_megamenu.module, line 481 - TB Mega Menu.
Code
function template_preprocess_tb_megamenu_block(array &$vars) {
$entity_block = \Drupal::service('tb_megamenu.menu_builder')
->loadEntityBlock($vars['block_id']);
if ($entity_block) {
$plugin = $entity_block
->getPlugin();
$plugin_configuration = $plugin
->getConfiguration();
$content = $plugin
->build();
if ($content) {
if (empty($vars['showblocktitle'])) {
$plugin_configuration['label_display'] = '';
}
$vars['content'] = [
'#theme' => 'block',
'#configuration' => $plugin_configuration,
'#plugin_id' => $plugin
->getPluginId(),
'#base_plugin_id' => $plugin
->getBaseId(),
'#derivative_plugin_id' => $plugin
->getDerivativeId(),
'content' => $content,
'#id' => $plugin_configuration['id'],
];
}
elseif ($vars['section'] == 'backend') {
$vars['content'] = $plugin_configuration['label'];
}
$vars['attributes'] = new Attribute();
$vars['attributes']['class'] = [];
$vars['attributes']['class'][] = "tb-block";
$theme_name = str_replace('_', '-', $vars['theme_hook_original']);
$vars['attributes']['class'][] = $theme_name;
$vars['attributes']['data-type'] = "block";
$vars['attributes']['data-block'] = $vars['block_id'];
}
else {
$vars['content'] = NULL;
}
}