HookAdminBlock.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file contains a Hook Event class for Admin Block.
  5. * @package chamilo.library.hook
  6. */
  7. /**
  8. * Class HookAdminBlock
  9. * This class is a Hook event implementing Admin Block Event interface.
  10. * This class is used to modify admin block by notifying Hook Observer for Admin Block
  11. */
  12. class HookAdminBlock extends HookEvent implements HookAdminBlockEventInterface
  13. {
  14. /**
  15. * Constructor
  16. */
  17. protected function __construct()
  18. {
  19. parent::__construct('HookAdminBlock');
  20. }
  21. /**
  22. * Notify Hook observers for Admin Block event
  23. * @param int $type Set the type of hook event called.
  24. * 0: HOOK_EVENT_TYPE_PRE, 1: HOOK_EVENT_TYPE_POST
  25. *
  26. * @return array|int
  27. */
  28. public function notifyAdminBlock($type)
  29. {
  30. /** @var \HookAdminBlockObserverInterface $observer */
  31. // Save data
  32. if (isset($this->eventData['blocks'])) {
  33. $this->eventData['type'] = $type;
  34. // Call all registered hook observers for admin block
  35. foreach ($this->observers as $observer) {
  36. $data = $observer->hookAdminBlock($this);
  37. if (isset($data['blocks'])) {
  38. // Get modified data
  39. $this->eventData['blocks'] = $data['blocks'];
  40. }
  41. }
  42. return $this->eventData;
  43. }
  44. return 0;
  45. }
  46. }