From 5bb6a7804f051111606be094f6ee183db0e3d2c7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 25 Jul 2023 11:40:42 +0200 Subject: [PATCH] fix: Move AppManager events to IEventDispatcher Signed-off-by: Joas Schilling --- lib/private/App/AppManager.php | 10 +++------- lib/private/Server.php | 1 - tests/lib/App/AppManagerTest.php | 16 +++++----------- tests/lib/AppTest.php | 1 - 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index b881d37440e..88044fbf7b6 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -59,7 +59,6 @@ use OCP\IUser; use OCP\IUserSession; use OCP\Settings\IManager as ISettingsManager; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; class AppManager implements IAppManager { /** @@ -79,7 +78,6 @@ class AppManager implements IAppManager { private AppConfig $appConfig; private IGroupManager $groupManager; private ICacheFactory $memCacheFactory; - private EventDispatcherInterface $legacyDispatcher; private IEventDispatcher $dispatcher; private LoggerInterface $logger; @@ -110,7 +108,6 @@ class AppManager implements IAppManager { AppConfig $appConfig, IGroupManager $groupManager, ICacheFactory $memCacheFactory, - EventDispatcherInterface $legacyDispatcher, IEventDispatcher $dispatcher, LoggerInterface $logger) { $this->userSession = $userSession; @@ -118,7 +115,6 @@ class AppManager implements IAppManager { $this->appConfig = $appConfig; $this->groupManager = $groupManager; $this->memCacheFactory = $memCacheFactory; - $this->legacyDispatcher = $legacyDispatcher; $this->dispatcher = $dispatcher; $this->logger = $logger; } @@ -543,7 +539,7 @@ class AppManager implements IAppManager { $this->installedAppsCache[$appId] = 'yes'; $this->appConfig->setValue($appId, 'enabled', 'yes'); $this->dispatcher->dispatchTyped(new AppEnableEvent($appId)); - $this->legacyDispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( + $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( ManagerEvent::EVENT_APP_ENABLE, $appId )); $this->clearAppsCache(); @@ -597,7 +593,7 @@ class AppManager implements IAppManager { $this->installedAppsCache[$appId] = json_encode($groupIds); $this->appConfig->setValue($appId, 'enabled', json_encode($groupIds)); $this->dispatcher->dispatchTyped(new AppEnableEvent($appId, $groupIds)); - $this->legacyDispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent( + $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent( ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, $appId, $groups )); $this->clearAppsCache(); @@ -633,7 +629,7 @@ class AppManager implements IAppManager { } $this->dispatcher->dispatchTyped(new AppDisableEvent($appId)); - $this->legacyDispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( + $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( ManagerEvent::EVENT_APP_DISABLE, $appId )); $this->clearAppsCache(); diff --git a/lib/private/Server.php b/lib/private/Server.php index 6239b20beee..520c1f1d249 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -939,7 +939,6 @@ class Server extends ServerContainer implements IServerContainer { $c->get(\OC\AppConfig::class), $c->get(IGroupManager::class), $c->get(ICacheFactory::class), - $c->get(SymfonyAdapter::class), $c->get(IEventDispatcher::class), $c->get(LoggerInterface::class) ); diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index d597b216041..4717da008a4 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -27,7 +27,6 @@ use OCP\IUser; use OCP\IUserSession; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -93,9 +92,6 @@ class AppManagerTest extends TestCase { /** @var ICacheFactory|MockObject */ protected $cacheFactory; - /** @var EventDispatcherInterface|MockObject */ - protected $legacyEventDispatcher; - /** @var IEventDispatcher|MockObject */ protected $eventDispatcher; @@ -114,7 +110,6 @@ class AppManagerTest extends TestCase { $this->appConfig = $this->getAppConfig(); $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->cache = $this->createMock(ICache::class); - $this->legacyEventDispatcher = $this->createMock(EventDispatcherInterface::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->logger = $this->createMock(LoggerInterface::class); $this->cacheFactory->expects($this->any()) @@ -127,7 +122,6 @@ class AppManagerTest extends TestCase { $this->appConfig, $this->groupManager, $this->cacheFactory, - $this->legacyEventDispatcher, $this->eventDispatcher, $this->logger ); @@ -176,7 +170,7 @@ class AppManagerTest extends TestCase { /** @var AppManager|MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) ->setConstructorArgs([ - $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->legacyEventDispatcher, $this->eventDispatcher, $this->logger + $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger ]) ->setMethods([ 'getAppPath', @@ -224,7 +218,7 @@ class AppManagerTest extends TestCase { /** @var AppManager|MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) ->setConstructorArgs([ - $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->legacyEventDispatcher, $this->eventDispatcher, $this->logger + $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger ]) ->setMethods([ 'getAppPath', @@ -280,7 +274,7 @@ class AppManagerTest extends TestCase { /** @var AppManager|MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) ->setConstructorArgs([ - $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->legacyEventDispatcher, $this->eventDispatcher, $this->logger + $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger ]) ->setMethods([ 'getAppPath', @@ -476,7 +470,7 @@ class AppManagerTest extends TestCase { public function testGetAppsNeedingUpgrade() { /** @var AppManager|MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) - ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->legacyEventDispatcher, $this->eventDispatcher, $this->logger]) + ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger]) ->setMethods(['getAppInfo']) ->getMock(); @@ -527,7 +521,7 @@ class AppManagerTest extends TestCase { public function testGetIncompatibleApps() { /** @var AppManager|MockObject $manager */ $manager = $this->getMockBuilder(AppManager::class) - ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->legacyEventDispatcher, $this->eventDispatcher, $this->logger]) + ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger]) ->setMethods(['getAppInfo']) ->getMock(); diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 5cdee5e1200..12fbdb011d9 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -560,7 +560,6 @@ class AppTest extends \Test\TestCase { $appConfig, \OC::$server->getGroupManager(), \OC::$server->getMemCacheFactory(), - \OC::$server->getEventDispatcher(), \OC::$server->get(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class) )); -- 2.39.5