GenericEntityEvent.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\WorkflowEngine;
  8. /**
  9. * Class GenericEntityEvent
  10. *
  11. *
  12. * @since 18.0.0
  13. */
  14. class GenericEntityEvent implements IEntityEvent {
  15. /** @var string */
  16. private $displayName;
  17. /** @var string */
  18. private $eventName;
  19. /**
  20. * GenericEntityEvent constructor.
  21. *
  22. * @since 18.0.0
  23. */
  24. public function __construct(string $displayName, string $eventName) {
  25. if (trim($displayName) === '') {
  26. throw new \InvalidArgumentException('DisplayName must not be empty');
  27. }
  28. if (trim($eventName) === '') {
  29. throw new \InvalidArgumentException('EventName must not be empty');
  30. }
  31. $this->displayName = trim($displayName);
  32. $this->eventName = trim($eventName);
  33. }
  34. /**
  35. * returns a translated name to be presented in the web interface.
  36. *
  37. * Example: "created" (en), "kreita" (eo)
  38. *
  39. * @since 18.0.0
  40. */
  41. public function getDisplayName(): string {
  42. return $this->displayName;
  43. }
  44. /**
  45. * returns the event name that is emitted by the EventDispatcher, e.g.:
  46. *
  47. * Example: "OCA\MyApp\Factory\Cats::postCreated"
  48. *
  49. * @since 18.0.0
  50. */
  51. public function getEventName(): string {
  52. return $this->eventName;
  53. }
  54. }