diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-08-09 13:24:48 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-09-09 22:56:01 +0200 |
commit | 804d4fe69feb1853846ad7a4b92f01cc637daf71 (patch) | |
tree | 94bf50f1c1cdde15a823cf6ab699b697bef4b521 /apps/workflowengine/lib/Manager.php | |
parent | 9a6f7cc8cb5aef8d0c9dfb29fbed4a02e331e647 (diff) | |
download | nextcloud-server-804d4fe69feb1853846ad7a4b92f01cc637daf71.tar.gz nextcloud-server-804d4fe69feb1853846ad7a4b92f01cc637daf71.zip |
introducing Entity interfaces and a File one as first implementation
also adds admin settings that pass entities as initial state
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/workflowengine/lib/Manager.php')
-rw-r--r-- | apps/workflowengine/lib/Manager.php | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index 23f62da4f8f..3a382f20dcd 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -23,6 +23,7 @@ namespace OCA\WorkflowEngine; use OC\Files\Storage\Wrapper\Jail; +use OCA\WorkflowEngine\Entity\File; use OCP\AppFramework\QueryException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Storage\IStorage; @@ -31,9 +32,12 @@ use OCP\IL10N; use OCP\ILogger; use OCP\IServerContainer; use OCP\WorkflowEngine\ICheck; +use OCP\WorkflowEngine\IEntity; use OCP\WorkflowEngine\IEntityAware; use OCP\WorkflowEngine\IManager; use OCP\WorkflowEngine\IOperation; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\GenericEvent; class Manager implements IManager, IEntityAware { @@ -61,15 +65,32 @@ class Manager implements IManager, IEntityAware { /** @var IL10N */ protected $l; + /** @var EventDispatcherInterface */ + protected $eventDispatcher; + + /** @var IEntity[] */ + protected $registeredEntities = []; + + /** @var ILogger */ + protected $logger; + /** * @param IDBConnection $connection * @param IServerContainer $container * @param IL10N $l */ - public function __construct(IDBConnection $connection, IServerContainer $container, IL10N $l) { + public function __construct( + IDBConnection $connection, + IServerContainer $container, + IL10N $l, + EventDispatcherInterface $eventDispatcher, + ILogger $logger + ) { $this->connection = $connection; $this->container = $container; $this->l = $l; + $this->eventDispatcher = $eventDispatcher; + $this->logger = $logger; } /** @@ -414,4 +435,37 @@ class Manager implements IManager, IEntityAware { } $this->entity = $entity; } + + /** + * @return IEntity[] + */ + public function getEntitiesList() { + $this->eventDispatcher->dispatch('OCP\WorkflowEngine::registerEntities', new GenericEvent($this)); + + return array_merge($this->getBuildInEntities(), $this->registeredEntities); + } + + /** + * Listen to 'OCP/WorkflowEngine::registerEntities' at the EventDispatcher + * for registering your entities + * + * @since 18.0.0 + */ + public function registerEntity(IEntity $entity): void { + $this->registeredEntities[$entity->getId()] = $entity; + } + + /** + * @return IEntity[] + */ + protected function getBuildInEntities(): array { + try { + return [ + $this->container->query(File::class), + ]; + } catch (QueryException $e) { + $this->logger->logException($e); + return []; + } + } } |