colossal_menu.module in Colossal Menu 2.x
Same filename and directory in other branches
Colossal Menu Hooks.
File
colossal_menu.moduleView source
<?php
/**
* @file
* Colossal Menu Hooks.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\Block\BlockPluginInterface;
/**
* Implements hook_theme().
*/
function colossal_menu_theme() {
return [
'colossal_menu' => [
'variables' => [
'menu_name' => NULL,
'items' => [],
'attributes' => [],
],
],
'colossal_menu_link' => [
'render element' => 'elements',
],
];
}
/**
* Prepares variables for Link templates.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_colossal_menu_link(array &$variables) {
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
/**
* Implements hook_block_view_BASE_BLOCK_ID_alter().
*/
function colossal_menu_block_view_colossal_menu_block_alter(array &$build, BlockPluginInterface $block) {
$build['#contextual_links']['colossal_menu'] = [
'route_parameters' => [
'colossal_menu' => $block
->getDerivativeId(),
],
];
}
Functions
Name | Description |
---|---|
colossal_menu_block_view_colossal_menu_block_alter | Implements hook_block_view_BASE_BLOCK_ID_alter(). |
colossal_menu_theme | Implements hook_theme(). |
template_preprocess_colossal_menu_link | Prepares variables for Link templates. |