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.

ManagerEvent.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP\SystemTag;
  28. use OCP\EventDispatcher\Event;
  29. /**
  30. * Class ManagerEvent
  31. *
  32. * @since 9.0.0
  33. */
  34. class ManagerEvent extends Event {
  35. /**
  36. * @deprecated 22.0.0
  37. */
  38. public const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag';
  39. /**
  40. * @deprecated 22.0.0
  41. */
  42. public const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag';
  43. /**
  44. * @deprecated 22.0.0
  45. */
  46. public const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag';
  47. /** @var string */
  48. protected $event;
  49. /** @var ISystemTag */
  50. protected $tag;
  51. /** @var ISystemTag */
  52. protected $beforeTag;
  53. /**
  54. * DispatcherEvent constructor.
  55. *
  56. * @param string $event
  57. * @param ISystemTag $tag
  58. * @param ISystemTag|null $beforeTag
  59. * @since 9.0.0
  60. */
  61. public function __construct(string $event, ISystemTag $tag, ISystemTag $beforeTag = null) {
  62. $this->event = $event;
  63. $this->tag = $tag;
  64. $this->beforeTag = $beforeTag;
  65. }
  66. /**
  67. * @return string
  68. * @since 9.0.0
  69. */
  70. public function getEvent(): string {
  71. return $this->event;
  72. }
  73. /**
  74. * @return ISystemTag
  75. * @since 9.0.0
  76. */
  77. public function getTag(): ISystemTag {
  78. return $this->tag;
  79. }
  80. /**
  81. * @return ISystemTag
  82. * @since 9.0.0
  83. * @throws \BadMethodCallException
  84. */
  85. public function getTagBefore(): ISystemTag {
  86. if ($this->event !== self::EVENT_UPDATE) {
  87. throw new \BadMethodCallException('getTagBefore is only available on the update Event');
  88. }
  89. return $this->beforeTag;
  90. }
  91. }