]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Move AppManager events to IEventDispatcher
authorJoas Schilling <coding@schilljs.com>
Tue, 25 Jul 2023 09:40:42 +0000 (11:40 +0200)
committerJoas Schilling <coding@schilljs.com>
Thu, 27 Jul 2023 07:57:51 +0000 (09:57 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/App/AppManager.php
lib/private/Server.php
tests/lib/App/AppManagerTest.php
tests/lib/AppTest.php

index b881d37440e9f8ba55804faf5ab488d15e1d06d1..88044fbf7b6f561e7e64223180954947e9312bfe 100644 (file)
@@ -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();
index 6239b20beee62b7f30c9e8e7b85d8938293c1c98..520c1f1d249e3c92e81f3b782f9093b6644f6794 100644 (file)
@@ -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)
                        );
index d597b21604111286b1c55c69448a12be8846f15b..4717da008a49e4243f8dbd34fed1cc251a2d0c89 100644 (file)
@@ -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();
 
index 5cdee5e1200682b80b736b9a36a27c60d70d325c..12fbdb011d9024a593829421e1f0a123572c6767 100644 (file)
@@ -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)
                ));