You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.1 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCP\App;
  25. use OCP\EventDispatcher\Event;
  26. /**
  27. * Class ManagerEvent
  28. *
  29. * @since 9.0.0
  30. */
  31. class ManagerEvent extends Event {
  32. public const EVENT_APP_ENABLE = 'OCP\App\IAppManager::enableApp';
  33. public const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups';
  34. public const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp';
  35. /**
  36. * @since 9.1.0
  37. */
  38. public const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp';
  39. /** @var string */
  40. protected $event;
  41. /** @var string */
  42. protected $appID;
  43. /** @var \OCP\IGroup[]|null */
  44. protected $groups;
  45. /**
  46. * DispatcherEvent constructor.
  47. *
  48. * @param string $event
  49. * @param $appID
  50. * @param \OCP\IGroup[]|null $groups
  51. * @since 9.0.0
  52. */
  53. public function __construct($event, $appID, array $groups = null) {
  54. $this->event = $event;
  55. $this->appID = $appID;
  56. $this->groups = $groups;
  57. }
  58. /**
  59. * @return string
  60. * @since 9.0.0
  61. */
  62. public function getEvent() {
  63. return $this->event;
  64. }
  65. /**
  66. * @return string
  67. * @since 9.0.0
  68. */
  69. public function getAppID() {
  70. return $this->appID;
  71. }
  72. /**
  73. * returns the group Ids
  74. * @return string[]
  75. * @since 9.0.0
  76. */
  77. public function getGroups() {
  78. return array_map(function ($group) {
  79. /** @var \OCP\IGroup $group */
  80. return $group->getGID();
  81. }, $this->groups);
  82. }
  83. }