IEntity.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  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
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\WorkflowEngine;
  25. use OCP\EventDispatcher\Event;
  26. /**
  27. * Interface IEntity
  28. *
  29. * This interface represents an entity that supports events the workflow engine
  30. * can listen to. For example a file with the create, update, etc. events.
  31. *
  32. * Ensure to listen to 'OCP/WorkflowEngine::loadEntities' for registering your
  33. * entities.
  34. *
  35. * @since 18.0.0
  36. */
  37. interface IEntity {
  38. /**
  39. * returns a translated name to be presented in the web interface.
  40. *
  41. * Example: "File" (en), "Dosiero" (eo)
  42. *
  43. * @since 18.0.0
  44. */
  45. public function getName(): string;
  46. /**
  47. * returns the URL to the icon of the entity for display in the web interface.
  48. *
  49. * Usually, the implementation would utilize the `imagePath()` method of the
  50. * `\OCP\IURLGenerator` instance and simply return its result.
  51. *
  52. * Example implementation: return $this->urlGenerator->imagePath('myApp', 'cat.svg');
  53. *
  54. * @since 18.0.0
  55. */
  56. public function getIcon(): string;
  57. /**
  58. * returns a list of supported events
  59. *
  60. * @return IEntityEvent[]
  61. * @since 18.0.0
  62. */
  63. public function getEvents(): array;
  64. /**
  65. * @since 18.0.0
  66. */
  67. public function prepareRuleMatcher(IRuleMatcher $ruleMatcher, string $eventName, Event $event): void;
  68. /**
  69. * returns whether the provided user id is allowed to run a flow against
  70. * the known context
  71. *
  72. * @since 18.0.0
  73. */
  74. public function isLegitimatedForUserId(string $userId): bool;
  75. }