tour_test.module 850 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @file
  4. * Provides tests for tour module
  5. */
  6. use Drupal\Core\Entity\EntityInterface;
  7. /**
  8. * Implements hook_ENTITY_TYPE_load() for tour.
  9. */
  10. function tour_test_tour_load($entities) {
  11. if (isset($entities['tour-entity-create-test-en'])) {
  12. $entities['tour-entity-create-test-en']->loaded = 'Load hooks work';
  13. }
  14. }
  15. /**
  16. * Implements hook_ENTITY_TYPE_presave() for tour.
  17. */
  18. function tour_test_tour_presave($entity) {
  19. if ($entity->id() == 'tour-entity-create-test-en') {
  20. $entity->set('label', $entity->label() . ' alter');
  21. }
  22. }
  23. /**
  24. * Implements hook_tour_tips_alter().
  25. */
  26. function tour_test_tour_tips_alter(array &$tour_tips, EntityInterface $entity) {
  27. foreach ($tour_tips as $tour_tip) {
  28. if ($tour_tip->get('id') == 'tour-code-test-1') {
  29. $tour_tip->set('body', 'Altered by hook_tour_tips_alter');
  30. }
  31. }
  32. }