summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/contextual/contextual.api.php
blob: 004947bf9b1471206c97d7a0c66968c72e950797 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

/**
 * @file
 * Hooks provided by Contextual module.
 */

/**
 * @addtogroup hooks
 * @{
 */

/**
 * Alter a contextual links element before it is rendered.
 *
 * This hook is invoked by
 * \Drupal\contextual\Element\ContextualLinks::preRenderLinks(). The renderable
 * array of #type 'contextual_links', containing the entire contextual links
 * data that is passed in by reference. Further links may be added or existing
 * links can be altered.
 *
 * @param array $element
 *   A renderable array representing the contextual links.
 * @param array $items
 *   An associative array containing the original contextual link items, as
 *   generated by
 *   \Drupal\Core\Menu\ContextualLinkManagerInterface::getContextualLinksArrayByGroup(),
 *   which were used to build $element['#links'].
 *
 * @see hook_contextual_links_alter()
 * @see hook_contextual_links_plugins_alter()
 * @see \Drupal\contextual\Element\ContextualLinks::preRenderLinks()
 */
function hook_contextual_links_view_alter(&$element, $items) {
  // Add another class to all contextual link lists to facilitate custom
  // styling.
  $element['#attributes']['class'][] = 'custom-class';
}

/**
 * @} End of "addtogroup hooks".
 */