open the WFE to deal with other subjects but files
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
d015cd9c55
commit
445d6eb839
4 changed files with 64 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
34
lib/public/WorkflowEngine/IEntityAware.php
Normal file
34
lib/public/WorkflowEngine/IEntityAware.php
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue