HookNotificationContent.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class HookNotificationContent
  5. * Hook Event class for Content format of Notifications.
  6. *
  7. * @package chamilo.library.hook
  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. }