contextual.api.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by Contextual module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Alter a contextual links element before it is rendered.
  12. *
  13. * This hook is invoked by contextual_pre_render_links(). The renderable array
  14. * of #type 'contextual_links', containing the entire contextual links data that
  15. * is passed in by reference. Further links may be added or existing links can
  16. * be altered.
  17. *
  18. * @param $element
  19. * A renderable array representing the contextual links.
  20. * @param $items
  21. * An associative array containing the original contextual link items, as
  22. * generated by
  23. * \Drupal\Core\Menu\ContextualLinkManagerInterface::getContextualLinksArrayByGroup(),
  24. * which were used to build $element['#links'].
  25. *
  26. * @see hook_contextual_links_alter()
  27. * @see hook_contextual_links_plugins_alter()
  28. * @see contextual_pre_render_links()
  29. */
  30. function hook_contextual_links_view_alter(&$element, $items) {
  31. // Add another class to all contextual link lists to facilitate custom
  32. // styling.
  33. $element['#attributes']['class'][] = 'custom-class';
  34. }
  35. /**
  36. * @} End of "addtogroup hooks".
  37. */