IOperation.php 3.2 KB

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