From c2a52813e2cfadc43b096927ee9d9db3d9ac5c84 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 5 Sep 2019 15:52:11 +0200 Subject: extends ICheck with scope and entity support, provide them as initialState Signed-off-by: Arthur Schiwon --- lib/public/WorkflowEngine/ICheck.php | 24 ++++++++++++++++++++++++ lib/public/WorkflowEngine/IManager.php | 17 +++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) (limited to 'lib/public/WorkflowEngine') diff --git a/lib/public/WorkflowEngine/ICheck.php b/lib/public/WorkflowEngine/ICheck.php index 1d4fc966460..92ec6f83893 100644 --- a/lib/public/WorkflowEngine/ICheck.php +++ b/lib/public/WorkflowEngine/ICheck.php @@ -55,4 +55,28 @@ interface ICheck { * @since 9.1 */ public function validateCheck($operator, $value); + + /** + * returns a list of Entities the checker supports. The values must match + * the class name of the entity. + * + * An empty result means the check is universally available. + * + * @since 18.0.0 + */ + public function supportedEntities(): array; + + /** + * returns whether the operation can be used in the requested scope. + * + * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At + * time of writing these are SCOPE_ADMIN and SCOPE_USER. + * + * For possibly unknown future scopes the recommended behaviour is: if + * user scope is permitted, the default behaviour should return `true`, + * otherwise `false`. + * + * @since 18.0.0 + */ + public function isAvailableForScope(int $scope): bool; } diff --git a/lib/public/WorkflowEngine/IManager.php b/lib/public/WorkflowEngine/IManager.php index 8ef7a3a03e8..8be47d961e7 100644 --- a/lib/public/WorkflowEngine/IManager.php +++ b/lib/public/WorkflowEngine/IManager.php @@ -39,6 +39,7 @@ interface IManager { const EVENT_NAME_REG_OPERATION = 'OCP\WorkflowEngine::registerOperations'; const EVENT_NAME_REG_ENTITY = 'OCP\WorkflowEngine::registerEntities'; + const EVENT_NAME_REG_CHECK = 'OCP\WorkflowEngine::registerChecks'; /** * @param IStorage $storage @@ -56,18 +57,26 @@ interface IManager { public function getMatchingOperations($class, $returnFirstMatchingOperationOnly = true); /** - * Listen to 'OCP/WorkflowEngine::registerEntities' at the EventDispatcher - * for registering your entities + * Listen to `\OCP\WorkflowEngine::EVENT_NAME_REG_ENTITY` at the + * EventDispatcher for registering your entities. * * @since 18.0.0 */ public function registerEntity(IEntity $entity): void; /** - * Listen to 'OCP/WorkflowEngine::registerOperators' at the EventDispatcher - * for registering your operators + * Listen to `\OCP\WorkflowEngine::EVENT_NAME_REG_OPERATION` at the + * EventDispatcher for registering your operators. * * @since 18.0.0 */ public function registerOperation(IOperation $operator): void; + + /** + * Listen to `\OCP\WorkflowEngine::EVENT_NAME_REG_CHECK` at the + * EventDispatcher for registering your operators. + * + * @since 18.0.0 + */ + public function registerCheck(ICheck $check): void; } -- cgit v1.2.3