HookWSRegistration.php 1.7 KB

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