HookEventInterface.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file contains all Hook interfaces and their relation.
  5. * They are used for Hook classes.
  6. *
  7. * @package chamilo.library.hook
  8. */
  9. /**
  10. * Interface HookEventInterface.
  11. */
  12. interface HookEventInterface
  13. {
  14. /**
  15. * Attach an HookObserver.
  16. *
  17. * @see http://php.net/manual/en/splsubject.attach.php
  18. *
  19. * @param \HookObserverInterface| $observer <p>
  20. * The <b>HookObserver</b> to attach.
  21. * </p>
  22. */
  23. public function attach(HookObserverInterface $observer);
  24. /**
  25. * Detach an HookObserver.
  26. *
  27. * @see http://php.net/manual/en/splsubject.detach.php
  28. *
  29. * @param \HookObserverInterface| $observer <p>
  30. * The <b>HookObserver</b> to detach.
  31. * </p>
  32. */
  33. public function detach(HookObserverInterface $observer);
  34. /**
  35. * Return the singleton instance of Hook event.
  36. *
  37. * @return static
  38. */
  39. public static function create();
  40. /**
  41. * Return an array containing all data needed by the hook observer to update.
  42. *
  43. * @return array
  44. */
  45. public function getEventData();
  46. /**
  47. * Set an array with data needed by hooks.
  48. *
  49. * @param array $data
  50. *
  51. * @return $this
  52. */
  53. public function setEventData(array $data);
  54. /**
  55. * Return the event name refer to where hook is used.
  56. *
  57. * @return string
  58. */
  59. public function getEventName();
  60. /**
  61. * Clear all hookObservers without detach them.
  62. *
  63. * @return mixed
  64. */
  65. public function clearAttachments();
  66. /**
  67. * Detach all hook observers.
  68. *
  69. * @return $this
  70. */
  71. public function detachAll();
  72. }