HookAdminBlock.php 1.4 KB

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