rules_link.api.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by this module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Acts on rules links being loaded from the database.
  12. *
  13. * This hook is invoked during rules link loading, which is handled by
  14. * entity_load(), via the EntityCRUDController.
  15. *
  16. * @param array $rules_links
  17. * An array of rules link entities being loaded, keyed by id.
  18. *
  19. * @see hook_entity_load()
  20. */
  21. function hook_rules_link_load(array $rules_links) {
  22. $result = db_query('SELECT pid, foo FROM {mytable} WHERE pid IN(:ids)', array(':ids' => array_keys($entities)));
  23. foreach ($result as $record) {
  24. $entities[$record->pid]->foo = $record->foo;
  25. }
  26. }
  27. /**
  28. * Responds when a rules link is inserted.
  29. *
  30. * This hook is invoked after the rules link is inserted into the database.
  31. *
  32. * @param RulesLink $rules_link
  33. * The rules link that is being inserted.
  34. *
  35. * @see hook_entity_insert()
  36. */
  37. function hook_rules_link_insert(RulesLink $rules_link) {
  38. db_insert('mytable')
  39. ->fields(array(
  40. 'id' => entity_id('rules_link', $rules_link),
  41. 'extra' => print_r($rules_link, TRUE),
  42. ))
  43. ->execute();
  44. }
  45. /**
  46. * Acts on a rules link being inserted or updated.
  47. *
  48. * This hook is invoked before the rules link is saved to the database.
  49. *
  50. * @param RulesLink $rules_link
  51. * The rules link that is being inserted or updated.
  52. *
  53. * @see hook_entity_presave()
  54. */
  55. function hook_rules_link_presave(RulesLink $rules_link) {
  56. $rules_link->name = 'foo';
  57. }
  58. /**
  59. * Responds to a rules link being updated.
  60. *
  61. * This hook is invoked after the rules link has been updated in the database.
  62. *
  63. * @param RulesLink $rules_link
  64. * The rules link that is being updated.
  65. *
  66. * @see hook_entity_update()
  67. */
  68. function hook_rules_link_update(RulesLink $rules_link) {
  69. db_update('mytable')
  70. ->fields(array('extra' => print_r($rules_link, TRUE)))
  71. ->condition('id', entity_id('rules_link', $rules_link))
  72. ->execute();
  73. }
  74. /**
  75. * Responds to rules link deletion.
  76. *
  77. * This hook is invoked after the rules link has been removed from the database.
  78. *
  79. * @param RulesLink $rules_link
  80. * The rules link that is being deleted.
  81. *
  82. * @see hook_entity_delete()
  83. */
  84. function hook_rules_link_delete(RulesLink $rules_link) {
  85. db_delete('mytable')
  86. ->condition('pid', entity_id('rules_link', $rules_link))
  87. ->execute();
  88. }
  89. /**
  90. * @}
  91. */