ManagerEvent.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\App;
  8. use OCP\EventDispatcher\Event;
  9. /**
  10. * Class ManagerEvent
  11. *
  12. * @since 9.0.0
  13. */
  14. class ManagerEvent extends Event {
  15. /**
  16. * @since 9.0.0
  17. * @deprecated 22.0.0
  18. */
  19. public const EVENT_APP_ENABLE = 'OCP\App\IAppManager::enableApp';
  20. /**
  21. * @since 9.0.0
  22. * @deprecated 22.0.0
  23. */
  24. public const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups';
  25. /**
  26. * @since 9.0.0
  27. * @deprecated 22.0.0
  28. */
  29. public const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp';
  30. /**
  31. * @since 9.1.0
  32. * @deprecated 22.0.0
  33. */
  34. public const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp';
  35. /** @var string */
  36. protected $event;
  37. /** @var string */
  38. protected $appID;
  39. /** @var \OCP\IGroup[]|null */
  40. protected $groups;
  41. /**
  42. * DispatcherEvent constructor.
  43. *
  44. * @param string $event
  45. * @param $appID
  46. * @param \OCP\IGroup[]|null $groups
  47. * @since 9.0.0
  48. */
  49. public function __construct($event, $appID, ?array $groups = null) {
  50. $this->event = $event;
  51. $this->appID = $appID;
  52. $this->groups = $groups;
  53. }
  54. /**
  55. * @return string
  56. * @since 9.0.0
  57. */
  58. public function getEvent() {
  59. return $this->event;
  60. }
  61. /**
  62. * @return string
  63. * @since 9.0.0
  64. */
  65. public function getAppID() {
  66. return $this->appID;
  67. }
  68. /**
  69. * returns the group Ids
  70. * @return string[]
  71. * @since 9.0.0
  72. */
  73. public function getGroups() {
  74. return array_map(function ($group) {
  75. /** @var \OCP\IGroup $group */
  76. return $group->getGID();
  77. }, $this->groups);
  78. }
  79. }