summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-08-07 12:12:56 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-09-09 22:56:01 +0200
commit445d6eb8394fa8db68f2f856d8a141eb1cebd34b (patch)
treec3f1eebcad779ec95d3fd92a8a5fe095d1782e3d
parentd015cd9c55b9e5b1e7899fbf7ae79fb5ab4c0beb (diff)
downloadnextcloud-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>
-rw-r--r--apps/workflowengine/lib/Manager.php30
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/public/WorkflowEngine/IEntityAware.php34
4 files changed, 64 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;
+ }
}
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 2c2b8889e26..bee32648915 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -439,6 +439,7 @@ return array(
'OCP\\User\\Backend\\ISetPasswordBackend' => $baseDir . '/lib/public/User/Backend/ISetPasswordBackend.php',
'OCP\\Util' => $baseDir . '/lib/public/Util.php',
'OCP\\WorkflowEngine\\ICheck' => $baseDir . '/lib/public/WorkflowEngine/ICheck.php',
+ 'OCP\\WorkflowEngine\\IEntityAware' => $baseDir . '/lib/public/WorkflowEngine/IEntityAware.php',
'OCP\\WorkflowEngine\\IManager' => $baseDir . '/lib/public/WorkflowEngine/IManager.php',
'OCP\\WorkflowEngine\\IOperation' => $baseDir . '/lib/public/WorkflowEngine/IOperation.php',
'OC\\Accounts\\Account' => $baseDir . '/lib/private/Accounts/Account.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 6bd401b4d77..eab2897df09 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -473,6 +473,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\User\\Backend\\ISetPasswordBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ISetPasswordBackend.php',
'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php',
'OCP\\WorkflowEngine\\ICheck' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/ICheck.php',
+ 'OCP\\WorkflowEngine\\IEntityAware' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IEntityAware.php',
'OCP\\WorkflowEngine\\IManager' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IManager.php',
'OCP\\WorkflowEngine\\IOperation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/IOperation.php',
'OC\\Accounts\\Account' => __DIR__ . '/../../..' . '/lib/private/Accounts/Account.php',
diff --git a/lib/public/WorkflowEngine/IEntityAware.php b/lib/public/WorkflowEngine/IEntityAware.php
new file mode 100644
index 00000000000..2ef74d2b115
--- /dev/null
+++ b/lib/public/WorkflowEngine/IEntityAware.php
@@ -0,0 +1,34 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\WorkflowEngine;
+
+
+interface IEntityAware {
+ /**
+ * @param object $entity
+ * @since 18.0.0
+ */
+ public function setEntity($entity);
+}