diff options
Diffstat (limited to 'apps/workflowengine/lib/Manager.php')
-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; + } } |