diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-08-07 12:12:56 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-09-09 22:56:01 +0200 |
commit | 445d6eb8394fa8db68f2f856d8a141eb1cebd34b (patch) | |
tree | c3f1eebcad779ec95d3fd92a8a5fe095d1782e3d /apps/workflowengine/lib | |
parent | d015cd9c55b9e5b1e7899fbf7ae79fb5ab4c0beb (diff) | |
download | nextcloud-server-445d6eb8394fa8db68f2f856d8a141eb1cebd34b.tar.gz nextcloud-server-445d6eb8394fa8db68f2f856d8a141eb1cebd34b.zip |
open the WFE to deal with other subjects but files
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/workflowengine/lib')
-rw-r--r-- | apps/workflowengine/lib/Manager.php | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index 32b04c1021d..23f62da4f8f 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -28,12 +28,14 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Storage\IStorage; use OCP\IDBConnection; use OCP\IL10N; +use OCP\ILogger; use OCP\IServerContainer; use OCP\WorkflowEngine\ICheck; +use OCP\WorkflowEngine\IEntityAware; use OCP\WorkflowEngine\IManager; use OCP\WorkflowEngine\IOperation; -class Manager implements IManager { +class Manager implements IManager, IEntityAware { /** @var IStorage */ protected $storage; @@ -41,6 +43,9 @@ class Manager implements IManager { /** @var string */ protected $path; + /** @var object */ + protected $entity; + /** @var array[] */ protected $operations = []; @@ -118,7 +123,10 @@ class Manager implements IManager { return true; } - if ($checkInstance instanceof ICheck) { + if ($checkInstance instanceof IEntityAware && $this->entity !== null) { + $checkInstance->setEntity($this->entity); + return $checkInstance->executeCheck($check['operator'], $check['value']); + } elseif ($checkInstance instanceof ICheck) { $checkInstance->setFileInfo($this->storage, $this->path); return $checkInstance->executeCheck($check['operator'], $check['value']); } else { @@ -388,4 +396,22 @@ class Manager implements IManager { return $operation; } + + /** + * @param object $entity + * @since 18.0.0 + */ + public function setEntity($entity) { + if(!is_object($entity)) { + $this->container->getLogger()->logException( + new \InvalidArgumentException('provided entity is not an object'), + [ + 'app' => 'workflowengine', + 'level' => ILogger::ERROR, + ] + ); + return; + } + $this->entity = $entity; + } } |