path.api.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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\AliasStorageInterface::save().
  16. *
  17. * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
  18. * hook_path_alias_insert() instead.
  19. *
  20. * @see https://www.drupal.org/node/3013865
  21. */
  22. function hook_path_insert($path) {
  23. \Drupal::database()->insert('mytable')
  24. ->fields([
  25. 'alias' => $path['alias'],
  26. 'pid' => $path['pid'],
  27. ])
  28. ->execute();
  29. }
  30. /**
  31. * Respond to a path being updated.
  32. *
  33. * @param array $path
  34. * The array structure is identical to that of the return value of
  35. * \Drupal\Core\Path\AliasStorageInterface::save().
  36. *
  37. * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
  38. * hook_path_alias_update() instead.
  39. *
  40. * @see https://www.drupal.org/node/3013865
  41. */
  42. function hook_path_update($path) {
  43. if ($path['alias'] != $path['original']['alias']) {
  44. \Drupal::database()->update('mytable')
  45. ->fields(['alias' => $path['alias']])
  46. ->condition('pid', $path['pid'])
  47. ->execute();
  48. }
  49. }
  50. /**
  51. * Respond to a path being deleted.
  52. *
  53. * @param array $path
  54. * The array structure is identical to that of the return value of
  55. * \Drupal\Core\Path\AliasStorageInterface::save().
  56. *
  57. * @deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use
  58. * hook_path_alias_delete() instead.
  59. *
  60. * @see https://www.drupal.org/node/3013865
  61. */
  62. function hook_path_delete($path) {
  63. \Drupal::database()->delete('mytable')
  64. ->condition('pid', $path['pid'])
  65. ->execute();
  66. }
  67. /**
  68. * @} End of "addtogroup hooks".
  69. */