ManagerEvent.php 2.0 KB

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