diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-12-22 17:04:39 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-02 18:40:49 +0300 |
commit | 25d4f3230d840d88191f905b2f3767d982c311b6 (patch) | |
tree | e37bb6b7784144a6c97800750aaa302637e04f0f /apps/workflowengine/lib | |
parent | c347b7cc148f69f12f7d8e98e3e6fee3a026d11c (diff) |
Use the new Events in Flow
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/workflowengine/lib')
-rw-r--r-- | apps/workflowengine/lib/Manager.php | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index 7e447a38a01..5ba2533ffe6 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -37,12 +37,16 @@ use OCA\WorkflowEngine\Helper\ScopeContext; use OCA\WorkflowEngine\Service\RuleMatcher; use OCP\AppFramework\QueryException; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Storage\IStorage; use OCP\IDBConnection; use OCP\IL10N; use OCP\ILogger; use OCP\IServerContainer; use OCP\IUserSession; +use OCP\WorkflowEngine\Events\RegisterChecksEvent; +use OCP\WorkflowEngine\Events\RegisterEntitiesEvent; +use OCP\WorkflowEngine\Events\RegisterOperationsEvent; use OCP\WorkflowEngine\ICheck; use OCP\WorkflowEngine\IComplexOperation; use OCP\WorkflowEngine\IEntity; @@ -50,7 +54,7 @@ use OCP\WorkflowEngine\IEntityEvent; use OCP\WorkflowEngine\IManager; use OCP\WorkflowEngine\IOperation; use OCP\WorkflowEngine\IRuleMatcher; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface as LegacyDispatcher; use Symfony\Component\EventDispatcher\GenericEvent; class Manager implements IManager { @@ -79,8 +83,8 @@ class Manager implements IManager { /** @var IL10N */ protected $l; - /** @var EventDispatcherInterface */ - protected $eventDispatcher; + /** @var LegacyDispatcher */ + protected $legacyEventDispatcher; /** @var IEntity[] */ protected $registeredEntities = []; @@ -100,26 +104,26 @@ class Manager implements IManager { /** @var IUserSession */ protected $session; - /** - * @param IDBConnection $connection - * @param IServerContainer $container - * @param IL10N $l - */ + /** @var IEventDispatcher */ + private $dispatcher; + public function __construct( IDBConnection $connection, IServerContainer $container, IL10N $l, - EventDispatcherInterface $eventDispatcher, + LegacyDispatcher $eventDispatcher, ILogger $logger, - IUserSession $session + IUserSession $session, + IEventDispatcher $dispatcher ) { $this->connection = $connection; $this->container = $container; $this->l = $l; - $this->eventDispatcher = $eventDispatcher; + $this->legacyEventDispatcher = $eventDispatcher; $this->logger = $logger; $this->operationsByScope = new CappedMemoryCache(64); $this->session = $session; + $this->dispatcher = $dispatcher; } public function getRuleMatcher(): IRuleMatcher { @@ -606,7 +610,8 @@ class Manager implements IManager { * @return IEntity[] */ public function getEntitiesList(): array { - $this->eventDispatcher->dispatch(IManager::EVENT_NAME_REG_ENTITY, new GenericEvent($this)); + $this->dispatcher->dispatchTyped(new RegisterEntitiesEvent($this)); + $this->legacyEventDispatcher->dispatch(IManager::EVENT_NAME_REG_ENTITY, new GenericEvent($this)); return array_values(array_merge($this->getBuildInEntities(), $this->registeredEntities)); } @@ -615,7 +620,8 @@ class Manager implements IManager { * @return IOperation[] */ public function getOperatorList(): array { - $this->eventDispatcher->dispatch(IManager::EVENT_NAME_REG_OPERATION, new GenericEvent($this)); + $this->dispatcher->dispatchTyped(new RegisterOperationsEvent($this)); + $this->legacyEventDispatcher->dispatch(IManager::EVENT_NAME_REG_OPERATION, new GenericEvent($this)); return array_merge($this->getBuildInOperators(), $this->registeredOperators); } @@ -624,7 +630,8 @@ class Manager implements IManager { * @return ICheck[] */ public function getCheckList(): array { - $this->eventDispatcher->dispatch(IManager::EVENT_NAME_REG_CHECK, new GenericEvent($this)); + $this->dispatcher->dispatchTyped(new RegisterChecksEvent($this)); + $this->legacyEventDispatcher->dispatch(IManager::EVENT_NAME_REG_CHECK, new GenericEvent($this)); return array_merge($this->getBuildInChecks(), $this->registeredChecks); } |