From d36365413210fc3adfd1214b174e68d8a340ee96 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 10 Sep 2019 00:52:27 +0200 Subject: [PATCH] fix order/entity types when setting the context Signed-off-by: Arthur Schiwon --- apps/workflowengine/lib/Service/RuleMatcher.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/workflowengine/lib/Service/RuleMatcher.php b/apps/workflowengine/lib/Service/RuleMatcher.php index bc92eeee818..bcfcd5dd219 100644 --- a/apps/workflowengine/lib/Service/RuleMatcher.php +++ b/apps/workflowengine/lib/Service/RuleMatcher.php @@ -36,6 +36,7 @@ use OCP\IServerContainer; use OCP\IUserSession; use OCP\WorkflowEngine\ICheck; use OCP\WorkflowEngine\IEntity; +use OCP\WorkflowEngine\IEntityCheck; use OCP\WorkflowEngine\IFileCheck; use OCP\WorkflowEngine\IManager; use OCP\WorkflowEngine\IRuleMatcher; @@ -117,21 +118,20 @@ class RuleMatcher implements IRuleMatcher { return true; } - if ($checkInstance instanceof ICheck) { + if ($checkInstance instanceof IFileCheck) { + if (empty($this->fileInfo)) { + throw new \RuntimeException('Must set file info before running the check'); + } + $checkInstance->setFileInfo($this->fileInfo['storage'], $this->fileInfo['path']); + } elseif ($checkInstance instanceof IEntityCheck) { foreach($this->contexts as $entityInfo) { list($entity, $subject) = $entityInfo; $checkInstance->setEntitySubject($entity, $subject); } - return $checkInstance->executeCheck($check['operator'], $check['value']); - } elseif ($checkInstance instanceof IFileCheck) { - if(empty($this->fileInfo)) { - throw new \RuntimeException('Must set file info before running the check'); - } - $checkInstance->setFileInfo($this->fileInfo['storage'], $this->fileInfo['path']); - return $checkInstance->executeCheck($check['operator'], $check['value']); } else { // Check is invalid throw new \UnexpectedValueException($this->l->t('Check %s is invalid or does not exist', $check['class'])); } + return $checkInstance->executeCheck($check['operator'], $check['value']); } }