fix order/entity types when setting the context

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2019-09-10 00:52:27 +02:00
parent 5610f73b7a
commit d363654132
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 8 additions and 8 deletions

View File

@ -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']);
}
}