IOperation.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. * @param int $scope
  72. * @psalm-param IManager::SCOPE_* $scope
  73. *
  74. * @since 18.0.0
  75. */
  76. public function isAvailableForScope(int $scope): bool;
  77. /**
  78. * Validates whether a configured workflow rule is valid. If it is not,
  79. * an `\UnexpectedValueException` is supposed to be thrown.
  80. *
  81. * @throws \UnexpectedValueException
  82. * @since 9.1
  83. */
  84. public function validateOperation(string $name, array $checks, string $operation): void;
  85. /**
  86. * Is being called by the workflow engine when an event was triggered that
  87. * is configured for this operation. An evaluation whether the event
  88. * qualifies for this operation to run has still to be done by the
  89. * implementor by calling the RuleMatchers getMatchingOperations method
  90. * and evaluating the results.
  91. *
  92. * If the implementor is an IComplexOperation, this method will not be
  93. * called automatically. It can be used or left as no-op by the implementor.
  94. *
  95. * @since 18.0.0
  96. */
  97. public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void;
  98. }