tour.api.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Describes API functions for tour module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Allow modules to alter tour items before render.
  12. *
  13. * @param array $tour_tips
  14. * Array of \Drupal\tour\TipPluginInterface items.
  15. * @param \Drupal\Core\Entity\EntityInterface $entity
  16. * The tour which contains the $tour_tips.
  17. */
  18. function hook_tour_tips_alter(array &$tour_tips, Drupal\Core\Entity\EntityInterface $entity) {
  19. foreach ($tour_tips as $tour_tip) {
  20. if ($tour_tip->get('id') == 'tour-code-test-1') {
  21. $tour_tip->set('body', 'Altered by hook_tour_tips_alter');
  22. }
  23. }
  24. }
  25. /**
  26. * Allow modules to alter tip plugin definitions.
  27. *
  28. * @param array $info
  29. * The array of tip plugin definitions, keyed by plugin ID.
  30. *
  31. * @see \Drupal\tour\Annotation\Tip
  32. */
  33. function hook_tour_tips_info_alter(&$info) {
  34. // Swap out the class used for this tip plugin.
  35. if (isset($info['text'])) {
  36. $info['class'] = 'Drupal\mymodule\Plugin\tour\tip\MyCustomTipPlugin';
  37. }
  38. }
  39. /**
  40. * @} End of "addtogroup hooks".
  41. */