HookNotificationTitle.php 1.3 KB

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