path.api.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Path module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Respond to a path being inserted.
  12. *
  13. * @param array $path
  14. * The array structure is identical to that of the return value of
  15. * \Drupal\Core\Path\PathInterface::save().
  16. *
  17. * @see \Drupal\Core\Path\PathInterface::save()
  18. */
  19. function hook_path_insert($path) {
  20. db_insert('mytable')
  21. ->fields([
  22. 'alias' => $path['alias'],
  23. 'pid' => $path['pid'],
  24. ])
  25. ->execute();
  26. }
  27. /**
  28. * Respond to a path being updated.
  29. *
  30. * @param array $path
  31. * The array structure is identical to that of the return value of
  32. * \Drupal\Core\Path\PathInterface::save().
  33. *
  34. * @see \Drupal\Core\Path\PathInterface::save()
  35. */
  36. function hook_path_update($path) {
  37. if ($path['alias'] != $path['original']['alias']) {
  38. db_update('mytable')
  39. ->fields(['alias' => $path['alias']])
  40. ->condition('pid', $path['pid'])
  41. ->execute();
  42. }
  43. }
  44. /**
  45. * Respond to a path being deleted.
  46. *
  47. * @param array $path
  48. * The array structure is identical to that of the return value of
  49. * \Drupal\Core\Path\PathInterface::save().
  50. *
  51. * @see \Drupal\Core\Path\PathInterface::delete()
  52. */
  53. function hook_path_delete($path) {
  54. db_delete('mytable')
  55. ->condition('pid', $path['pid'])
  56. ->execute();
  57. }
  58. /**
  59. * @} End of "addtogroup hooks".
  60. */