HookNotificationContent.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class HookNotificationContent
  5. * Hook Event class for Content format of Notifications
  6. * @package chamilo.library.hook
  7. *
  8. */
  9. class HookNotificationContent extends HookEvent implements HookNotificationContentEventInterface
  10. {
  11. /**
  12. * Construct
  13. */
  14. protected function __construct()
  15. {
  16. parent::__construct('HookNotificationContent');
  17. }
  18. /**
  19. * @param int $type
  20. *
  21. * @return array|null
  22. */
  23. public function notifyNotificationContent($type)
  24. {
  25. /** @var \HookNotificationContentObserverInterface $observer */
  26. // Check if exists data content
  27. if (isset($this->eventData['content'])) {
  28. // Save data type
  29. $this->eventData['type'] = $type;
  30. // Check for hook all registered observers
  31. foreach ($this->observers as $observer) {
  32. $data = $observer->hookNotificationContent($this);
  33. // Check if isset content
  34. if (isset($data['content'])) {
  35. // Set data from hook observer data
  36. $this->setEventData($data);
  37. }
  38. }
  39. return $this->eventData;
  40. }
  41. return null;
  42. }
  43. }