diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-07-26 17:29:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 17:29:22 +0200 |
commit | b76b0bbc1ca8226cd8b4ca9dbab2649c2275e7bd (patch) | |
tree | 00cebb57990f6a379151ba45c9780ac7d83bde15 /apps | |
parent | 19e7704c85d0e8aa1c8ea2ca7e8bf47d549ec0e2 (diff) | |
parent | 77bc6c32d8b7cfe65f6a0e4ba303997a22f075d7 (diff) | |
download | nextcloud-server-b76b0bbc1ca8226cd8b4ca9dbab2649c2275e7bd.tar.gz nextcloud-server-b76b0bbc1ca8226cd8b4ca9dbab2649c2275e7bd.zip |
Merge pull request #39485 from nextcloud/bugfix/noid/move-remaining-easy-usages-to-IEventDispatcher
fix(dispatcher): Move remaining simple cases in apps/ folder to IEven…
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/RootCollection.php | 2 | ||||
-rw-r--r-- | apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php | 17 | ||||
-rw-r--r-- | apps/files/lib/Collaboration/Resources/Listener.php | 4 | ||||
-rw-r--r-- | apps/files/tests/Controller/ViewControllerTest.php | 3 | ||||
-rw-r--r-- | apps/files_external/tests/Controller/StoragesControllerTest.php | 8 | ||||
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 17 | ||||
-rw-r--r-- | apps/files_sharing/tests/ApplicationTest.php | 8 | ||||
-rw-r--r-- | apps/user_ldap/lib/AppInfo/Application.php | 6 | ||||
-rw-r--r-- | apps/workflowengine/tests/ManagerTest.php | 1 |
9 files changed, 26 insertions, 40 deletions
diff --git a/apps/dav/lib/RootCollection.php b/apps/dav/lib/RootCollection.php index e4fd814ed81..90be581a2a9 100644 --- a/apps/dav/lib/RootCollection.php +++ b/apps/dav/lib/RootCollection.php @@ -132,7 +132,7 @@ class RootCollection extends SimpleCollection { \OC::$server->getSystemTagObjectMapper(), \OC::$server->getUserSession(), $groupManager, - \OC::$server->getEventDispatcher() + $dispatcher ); $systemTagInUseCollection = \OCP\Server::get(SystemTag\SystemTagsInUseCollection::class); $commentsCollection = new Comments\RootCollection( diff --git a/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php b/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php index 4c179d5f0f6..6c44713cb05 100644 --- a/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php +++ b/apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php @@ -26,6 +26,7 @@ */ namespace OCA\DAV\SystemTag; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IGroupManager; use OCP\IUserSession; use OCP\SystemTag\ISystemTagManager; @@ -33,25 +34,14 @@ use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\SystemTagsEntityEvent; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\SimpleCollection; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; class SystemTagsRelationsCollection extends SimpleCollection { - - /** - * SystemTagsRelationsCollection constructor. - * - * @param ISystemTagManager $tagManager - * @param ISystemTagObjectMapper $tagMapper - * @param IUserSession $userSession - * @param IGroupManager $groupManager - * @param EventDispatcherInterface $dispatcher - */ public function __construct( ISystemTagManager $tagManager, ISystemTagObjectMapper $tagMapper, IUserSession $userSession, IGroupManager $groupManager, - EventDispatcherInterface $dispatcher + IEventDispatcher $dispatcher, ) { $children = [ new SystemTagsObjectTypeCollection( @@ -67,8 +57,9 @@ class SystemTagsRelationsCollection extends SimpleCollection { ), ]; - $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY); + $event = new SystemTagsEntityEvent(); $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event); + $dispatcher->dispatchTyped($event); foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) { $children[] = new SystemTagsObjectTypeCollection( diff --git a/apps/files/lib/Collaboration/Resources/Listener.php b/apps/files/lib/Collaboration/Resources/Listener.php index 64dd693a4da..28ce5f87897 100644 --- a/apps/files/lib/Collaboration/Resources/Listener.php +++ b/apps/files/lib/Collaboration/Resources/Listener.php @@ -25,12 +25,12 @@ declare(strict_types=1); */ namespace OCA\Files\Collaboration\Resources; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Server; use OCP\Collaboration\Resources\IManager; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; class Listener { - public static function register(EventDispatcherInterface $dispatcher): void { + public static function register(IEventDispatcher $dispatcher): void { $dispatcher->addListener('OCP\Share::postShare', [self::class, 'shareModification']); $dispatcher->addListener('OCP\Share::postUnshare', [self::class, 'shareModification']); $dispatcher->addListener('OCP\Share::postUnshareFromSelf', [self::class, 'shareModification']); diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 05f35f32f0a..2fa98be9fcd 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -52,7 +52,6 @@ use OCP\IUser; use OCP\IUserSession; use OCP\Share\IManager; use OCP\Template; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -69,7 +68,7 @@ class ViewControllerTest extends TestCase { private $l10n; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @var EventDispatcherInterface */ + /** @var IEventDispatcher */ private $eventDispatcher; /** @var ViewController|\PHPUnit\Framework\MockObject\MockObject */ private $viewController; diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php index bb9be2f2d4a..5b3eb6d7983 100644 --- a/apps/files_external/tests/Controller/StoragesControllerTest.php +++ b/apps/files_external/tests/Controller/StoragesControllerTest.php @@ -34,7 +34,9 @@ use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\NotFoundException; use OCA\Files_External\Service\GlobalStoragesService; +use OCA\Files_External\Service\UserStoragesService; use OCP\AppFramework\Http; +use PHPUnit\Framework\MockObject\MockObject; abstract class StoragesControllerTest extends \Test\TestCase { @@ -44,7 +46,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { protected $controller; /** - * @var GlobalStoragesService + * @var GlobalStoragesService|UserStoragesService|MockObject */ protected $service; @@ -57,7 +59,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { } /** - * @return \OCA\Files_External\Lib\Backend\Backend + * @return \OCA\Files_External\Lib\Backend\Backend|MockObject */ protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') { $backend = $this->getMockBuilder(Backend::class) @@ -73,7 +75,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { } /** - * @return \OCA\Files_External\Lib\Auth\AuthMechanism + * @return \OCA\Files_External\Lib\Auth\AuthMechanism|MockObject */ protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { $authMech = $this->getMockBuilder(AuthMechanism::class) diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 946d82a3df7..65197e9b270 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -51,7 +51,6 @@ use OCA\Files_Sharing\Notification\Listener; use OCA\Files_Sharing\Notification\Notifier; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadSidebar; -use OCP\Files\Event\BeforeDirectGetEvent; use OCA\Files_Sharing\ShareBackend\File; use OCA\Files_Sharing\ShareBackend\Folder; use OCA\Files_Sharing\ViewOnly; @@ -61,7 +60,6 @@ use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent as ResourcesLoadAdditionalScriptsEvent; use OCP\EventDispatcher\IEventDispatcher; -use OCP\EventDispatcher\GenericEvent; use OCP\Federation\ICloudIdManager; use OCP\Files\Config\IMountProviderCollection; use OCP\Files\Events\BeforeDirectFileDownloadEvent; @@ -72,13 +70,10 @@ use OCP\Group\Events\UserAddedEvent; use OCP\IDBConnection; use OCP\IGroup; use OCP\IUserSession; -use OCP\L10N\IFactory; use OCP\Share\Events\ShareCreatedEvent; -use OCP\Share\IManager; use OCP\User\Events\UserChangedEvent; use OCP\Util; use Psr\Container\ContainerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent as OldGenericEvent; class Application extends App implements IBootstrap { @@ -135,7 +130,7 @@ class Application extends App implements IBootstrap { $mountProviderCollection->registerProvider($externalMountProvider); } - public function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher): void { + public function registerEventsScripts(IEventDispatcher $dispatcher): void { // sidebar and files scripts $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class); @@ -148,12 +143,18 @@ class Application extends App implements IBootstrap { }); // notifications api to accept incoming user shares - $oldDispatcher->addListener('OCP\Share::postShare', function (OldGenericEvent $event) { + $dispatcher->addListener('OCP\Share::postShare', function ($event) { + if (!$event instanceof OldGenericEvent) { + return; + } /** @var Listener $listener */ $listener = $this->getContainer()->query(Listener::class); $listener->shareNotification($event); }); - $oldDispatcher->addListener(IGroup::class . '::postAddUser', function (OldGenericEvent $event) { + $dispatcher->addListener(IGroup::class . '::postAddUser', function ($event) { + if (!$event instanceof OldGenericEvent) { + return; + } /** @var Listener $listener */ $listener = $this->getContainer()->query(Listener::class); $listener->userAddedToGroup($event); diff --git a/apps/files_sharing/tests/ApplicationTest.php b/apps/files_sharing/tests/ApplicationTest.php index 11c8137c398..d16aed61bf7 100644 --- a/apps/files_sharing/tests/ApplicationTest.php +++ b/apps/files_sharing/tests/ApplicationTest.php @@ -25,16 +25,11 @@ namespace OCA\Files_Sharing\Tests; use OCP\Files\Events\BeforeDirectFileDownloadEvent; use OCP\Files\Events\BeforeZipCreatedEvent; use Psr\Log\LoggerInterface; -use OC\Share20\LegacyHooks; use OC\Share20\Manager; use OC\EventDispatcher\EventDispatcher; use OCA\Files_Sharing\AppInfo\Application; use OCA\Files_Sharing\SharedStorage; -use OCP\Constants; -use OCP\EventDispatcher\GenericEvent; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Files\Cache\ICacheEntry; -use OCP\Files\Event\BeforeDirectGetEvent; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; @@ -57,7 +52,8 @@ class ApplicationTest extends TestCase { /** @var IRootFolder */ private $rootFolder; - /** @var Manager */ private $manager; + /** @var Manager */ + private $manager; protected function setUp(): void { parent::setUp(); diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php index 757ac141d3d..d6fb062a028 100644 --- a/apps/user_ldap/lib/AppInfo/Application.php +++ b/apps/user_ldap/lib/AppInfo/Application.php @@ -59,7 +59,6 @@ use OCP\Notification\IManager as INotificationManager; use OCP\Share\IManager as IShareManager; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; class Application extends App implements IBootstrap { public function __construct() { @@ -120,7 +119,6 @@ class Application extends App implements IBootstrap { $context->injectFn(function ( INotificationManager $notificationManager, IAppContainer $appContainer, - EventDispatcherInterface $legacyDispatcher, IEventDispatcher $dispatcher, IGroupManager $groupManager, User_Proxy $userBackend, @@ -136,7 +134,7 @@ class Application extends App implements IBootstrap { $groupManager->addBackend($groupBackend); $userBackendRegisteredEvent = new UserBackendRegistered($userBackend, $userPluginManager); - $legacyDispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded', $userBackendRegisteredEvent); + $dispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded', $userBackendRegisteredEvent); $dispatcher->dispatchTyped($userBackendRegisteredEvent); $groupBackendRegisteredEvent = new GroupBackendRegistered($groupBackend, $groupPluginManager); $dispatcher->dispatchTyped($groupBackendRegisteredEvent); @@ -153,7 +151,7 @@ class Application extends App implements IBootstrap { ); } - private function registerBackendDependents(IAppContainer $appContainer, EventDispatcherInterface $dispatcher) { + private function registerBackendDependents(IAppContainer $appContainer, IEventDispatcher $dispatcher) { $dispatcher->addListener( 'OCA\\Files_External::loadAdditionalBackends', function () use ($appContainer) { diff --git a/apps/workflowengine/tests/ManagerTest.php b/apps/workflowengine/tests/ManagerTest.php index dee6b508454..213daf49415 100644 --- a/apps/workflowengine/tests/ManagerTest.php +++ b/apps/workflowengine/tests/ManagerTest.php @@ -52,7 +52,6 @@ use OCP\WorkflowEngine\IEntityEvent; use OCP\WorkflowEngine\IManager; use OCP\WorkflowEngine\IOperation; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** |