Skip to content

Commit

Permalink
fix(workflowengine): Remove legacy event (deprecated since 17)
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 19, 2023
1 parent 4877d0b commit aa039c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
10 changes: 0 additions & 10 deletions apps/workflowengine/lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
use OCP\WorkflowEngine\IManager;
use OCP\WorkflowEngine\IOperation;
use OCP\WorkflowEngine\IRuleMatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface as LegacyDispatcher;
use Symfony\Component\EventDispatcher\GenericEvent;

class Manager implements IManager {
/** @var IStorage */
Expand All @@ -94,9 +92,6 @@ class Manager implements IManager {
/** @var IL10N */
protected $l;

/** @var LegacyDispatcher */
protected $legacyEventDispatcher;

/** @var IEntity[] */
protected $registeredEntities = [];

Expand Down Expand Up @@ -126,7 +121,6 @@ public function __construct(
IDBConnection $connection,
IServerContainer $container,
IL10N $l,
LegacyDispatcher $eventDispatcher,
ILogger $logger,
IUserSession $session,
IEventDispatcher $dispatcher,
Expand All @@ -136,7 +130,6 @@ public function __construct(
$this->connection = $connection;
$this->container = $container;
$this->l = $l;
$this->legacyEventDispatcher = $eventDispatcher;
$this->logger = $logger;
$this->operationsByScope = new CappedMemoryCache(64);
$this->session = $session;
Expand Down Expand Up @@ -694,7 +687,6 @@ public function formatOperation(array $operation): array {
*/
public function getEntitiesList(): array {
$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));
}
Expand All @@ -704,7 +696,6 @@ public function getEntitiesList(): array {
*/
public function getOperatorList(): array {
$this->dispatcher->dispatchTyped(new RegisterOperationsEvent($this));
$this->legacyEventDispatcher->dispatch(IManager::EVENT_NAME_REG_OPERATION, new GenericEvent($this));

return array_merge($this->getBuildInOperators(), $this->registeredOperators);
}
Expand All @@ -714,7 +705,6 @@ public function getOperatorList(): array {
*/
public function getCheckList(): array {
$this->dispatcher->dispatchTyped(new RegisterChecksEvent($this));
$this->legacyEventDispatcher->dispatch(IManager::EVENT_NAME_REG_CHECK, new GenericEvent($this));

return array_merge($this->getBuildInChecks(), $this->registeredChecks);
}
Expand Down
12 changes: 4 additions & 8 deletions apps/workflowengine/tests/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\SystemTag\ISystemTagManager;
use OCP\WorkflowEngine\Events\RegisterEntitiesEvent;
use OCP\WorkflowEngine\ICheck;
use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IEntityEvent;
Expand All @@ -67,8 +68,6 @@ class ManagerTest extends TestCase {
protected $db;
/** @var \PHPUnit\Framework\MockObject\MockObject|ILogger */
protected $logger;
/** @var \PHPUnit\Framework\MockObject\MockObject|EventDispatcherInterface */
protected $legacyDispatcher;
/** @var MockObject|IServerContainer */
protected $container;
/** @var MockObject|IUserSession */
Expand All @@ -94,7 +93,6 @@ protected function setUp(): void {
return vsprintf($text, $parameters);
});

$this->legacyDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->logger = $this->createMock(ILogger::class);
$this->session = $this->createMock(IUserSession::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
Expand All @@ -105,7 +103,6 @@ protected function setUp(): void {
\OC::$server->getDatabaseConnection(),
$this->container,
$this->l,
$this->legacyDispatcher,
$this->logger,
$this->session,
$this->dispatcher,
Expand Down Expand Up @@ -532,10 +529,9 @@ public function testGetEntitiesList() {
/** @var MockObject|IEntity $extraEntity */
$extraEntity = $this->createMock(IEntity::class);

$this->legacyDispatcher->expects($this->once())
->method('dispatch')
->with('OCP\WorkflowEngine::registerEntities', $this->anything())
->willReturnCallback(function () use ($extraEntity) {
$this->dispatcher->expects($this->once())
->method('dispatchTyped')
->willReturnCallback(function (RegisterEntitiesEvent $e) use ($extraEntity) {
$this->manager->registerEntity($extraEntity);
});

Expand Down
15 changes: 0 additions & 15 deletions lib/public/WorkflowEngine/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@ interface IManager {
*/
public const MAX_OPERATION_VALUE_BYTES = 4096;

/**
* @deprecated 17.0.0 Will be removed in NC19. Use the dedicated events in OCP\WorkflowEngine\Events
*/
public const EVENT_NAME_REG_OPERATION = 'OCP\WorkflowEngine::registerOperations';

/**
* @deprecated 17.0.0
*/
public const EVENT_NAME_REG_ENTITY = 'OCP\WorkflowEngine::registerEntities';

/**
* @deprecated 17.0.0
*/
public const EVENT_NAME_REG_CHECK = 'OCP\WorkflowEngine::registerChecks';

/**
* Listen to `OCP\WorkflowEngine\Events\RegisterEntitiesEvent` at the
* IEventDispatcher for registering your entities.
Expand Down

0 comments on commit aa039c9

Please sign in to comment.