Drupal investigation

path.api.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. */