Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-12-22 17:04:39 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2020-01-02 18:40:49 +0300
commit25d4f3230d840d88191f905b2f3767d982c311b6 (patch)
treee37bb6b7784144a6c97800750aaa302637e04f0f /apps
parentc347b7cc148f69f12f7d8e98e3e6fee3a026d11c (diff)
Use the new Events in Flow
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/workflowengine/lib/Manager.php35
-rw-r--r--apps/workflowengine/tests/ManagerTest.php15
2 files changed, 31 insertions, 19 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);
}
diff --git a/apps/workflowengine/tests/ManagerTest.php b/apps/workflowengine/tests/ManagerTest.php
index 82f1653ef25..22d323a9436 100644
--- a/apps/workflowengine/tests/ManagerTest.php
+++ b/apps/workflowengine/tests/ManagerTest.php
@@ -26,6 +26,7 @@ use OC\L10N\L10N;
use OCA\WorkflowEngine\Entity\File;
use OCA\WorkflowEngine\Helper\ScopeContext;
use OCA\WorkflowEngine\Manager;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\IDBConnection;
use OCP\IL10N;
@@ -57,13 +58,15 @@ class ManagerTest extends TestCase {
/** @var \PHPUnit\Framework\MockObject\MockObject|ILogger */
protected $logger;
/** @var \PHPUnit\Framework\MockObject\MockObject|EventDispatcherInterface */
- protected $eventDispatcher;
+ protected $legacyDispatcher;
/** @var MockObject|IServerContainer */
protected $container;
/** @var MockObject|IUserSession */
protected $session;
/** @var MockObject|L10N */
protected $l;
+ /** @var MockObject|IEventDispatcher */
+ protected $dispatcher;
protected function setUp(): void {
parent::setUp();
@@ -77,17 +80,19 @@ class ManagerTest extends TestCase {
return vsprintf($text, $parameters);
}));
- $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
+ $this->legacyDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->logger = $this->createMock(ILogger::class);
$this->session = $this->createMock(IUserSession::class);
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
$this->manager = new Manager(
\OC::$server->getDatabaseConnection(),
$this->container,
$this->l,
- $this->eventDispatcher,
+ $this->legacyDispatcher,
$this->logger,
- $this->session
+ $this->session,
+ $this->dispatcher
);
$this->clearTables();
}
@@ -402,7 +407,7 @@ class ManagerTest extends TestCase {
/** @var MockObject|IEntity $extraEntity */
$extraEntity = $this->createMock(IEntity::class);
- $this->eventDispatcher->expects($this->once())
+ $this->legacyDispatcher->expects($this->once())
->method('dispatch')
->with('OCP\WorkflowEngine::registerEntities', $this->anything())
->willReturnCallback(function() use ($extraEntity) {