GenericEntityEvent.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de>
  5. *
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCP\WorkflowEngine;
  27. /**
  28. * Class GenericEntityEvent
  29. *
  30. *
  31. * @since 18.0.0
  32. */
  33. class GenericEntityEvent implements IEntityEvent {
  34. /** @var string */
  35. private $displayName;
  36. /** @var string */
  37. private $eventName;
  38. /**
  39. * GenericEntityEvent constructor.
  40. *
  41. * @since 18.0.0
  42. */
  43. public function __construct(string $displayName, string $eventName) {
  44. if (trim($displayName) === '') {
  45. throw new \InvalidArgumentException('DisplayName must not be empty');
  46. }
  47. if (trim($eventName) === '') {
  48. throw new \InvalidArgumentException('EventName must not be empty');
  49. }
  50. $this->displayName = trim($displayName);
  51. $this->eventName = trim($eventName);
  52. }
  53. /**
  54. * returns a translated name to be presented in the web interface.
  55. *
  56. * Example: "created" (en), "kreita" (eo)
  57. *
  58. * @since 18.0.0
  59. */
  60. public function getDisplayName(): string {
  61. return $this->displayName;
  62. }
  63. /**
  64. * returns the event name that is emitted by the EventDispatcher, e.g.:
  65. *
  66. * Example: "OCA\MyApp\Factory\Cats::postCreated"
  67. *
  68. * @since 18.0.0
  69. */
  70. public function getEventName(): string {
  71. return $this->eventName;
  72. }
  73. }