HookWSRegistration.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 HookWSRegistration
  10. * This class is a Hook event implementing Webservice Registration Event interface.
  11. * This class is used to modify ws for registration by notifying Hook Observer
  12. * for Webservice registration.
  13. */
  14. class HookWSRegistration extends HookEvent implements HookWSRegistrationEventInterface
  15. {
  16. /**
  17. * Construct.
  18. */
  19. protected function __construct()
  20. {
  21. parent::__construct('HookWSRegistration');
  22. }
  23. /**
  24. * Notify all Hook observer for WS Registration.
  25. * This save "server" (soap server) and send to Hook observer to be modified
  26. * (e.g. add more registration webservice).
  27. *
  28. * @param int $type Set the type of hook event called.
  29. * 0: HOOK_EVENT_TYPE_PRE, 1: HOOK_EVENT_TYPE_POST
  30. *
  31. * @return int
  32. */
  33. public function notifyWSRegistration($type)
  34. {
  35. /** @var \HookWSRegistrationObserverInterface $observer */
  36. // check if already have server data
  37. if (isset($this->eventData['server'])) {
  38. // Save Hook event type data
  39. $this->eventData['type'] = $type;
  40. foreach ($this->observers as $observer) {
  41. // Notify all registered observers
  42. $data = $observer->hookWSRegistration($this);
  43. // check if server is not null
  44. if (isset($data['server'])) {
  45. // Get modified server
  46. $this->eventData['server'] = $data['server'];
  47. }
  48. }
  49. return $this->eventData;
  50. }
  51. return 1;
  52. }
  53. }