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.

103 lines
3.2 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Joas Schilling <coding@schilljs.com>
  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 IOperation
  28. *
  29. * @since 9.1
  30. */
  31. interface IOperation {
  32. /**
  33. * returns a translated name to be presented in the web interface
  34. *
  35. * Example: "Automated tagging" (en), "Aŭtomata etikedado" (eo)
  36. *
  37. * @since 18.0.0
  38. */
  39. public function getDisplayName(): string;
  40. /**
  41. * returns a translated, descriptive text to be presented in the web interface.
  42. *
  43. * It should be short and precise.
  44. *
  45. * Example: "Tag based automatic deletion of files after a given time." (en)
  46. *
  47. * @since 18.0.0
  48. */
  49. public function getDescription(): string;
  50. /**
  51. * returns the URL to the icon of the operator for display in the web interface.
  52. *
  53. * Usually, the implementation would utilize the `imagePath()` method of the
  54. * `\OCP\IURLGenerator` instance and simply return its result.
  55. *
  56. * Example implementation: return $this->urlGenerator->imagePath('myApp', 'cat.svg');
  57. *
  58. * @since 18.0.0
  59. */
  60. public function getIcon(): string;
  61. /**
  62. * returns whether the operation can be used in the requested scope.
  63. *
  64. * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At
  65. * time of writing these are SCOPE_ADMIN and SCOPE_USER.
  66. *
  67. * For possibly unknown future scopes the recommended behaviour is: if
  68. * user scope is permitted, the default behaviour should return `true`,
  69. * otherwise `false`.
  70. *
  71. * @since 18.0.0
  72. */
  73. public function isAvailableForScope(int $scope): bool;
  74. /**
  75. * Validates whether a configured workflow rule is valid. If it is not,
  76. * an `\UnexpectedValueException` is supposed to be thrown.
  77. *
  78. * @throws \UnexpectedValueException
  79. * @since 9.1
  80. */
  81. public function validateOperation(string $name, array $checks, string $operation): void;
  82. /**
  83. * Is being called by the workflow engine when an event was triggered that
  84. * is configured for this operation. An evaluation whether the event
  85. * qualifies for this operation to run has still to be done by the
  86. * implementor by calling the RuleMatchers getMatchingOperations method
  87. * and evaluating the results.
  88. *
  89. * If the implementor is an IComplexOperation, this method will not be
  90. * called automatically. It can be used or left as no-op by the implementor.
  91. *
  92. * @since 18.0.0
  93. */
  94. public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void;
  95. }