From 27a0eaee57a30bf6a344377a6f0620d642bff1af Mon Sep 17 00:00:00 2001 From: Andrew Summers <18727110+summersab@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:20:39 -0500 Subject: [PATCH] Refactor `OC\Server::getGroupManager` Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com> fix accidental method name mistake Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com> --- core/register_command.php | 22 ++++++++++--------- .../DependencyInjection/DIContainer.php | 3 ++- lib/private/Encryption/EncryptionWrapper.php | 3 ++- lib/private/Encryption/HookManager.php | 3 ++- lib/private/Repair.php | 5 +++-- lib/private/Setup.php | 3 ++- lib/private/Share/Share.php | 5 +++-- lib/private/Share20/ProviderFactory.php | 3 ++- lib/private/SystemTag/ManagerFactory.php | 3 ++- lib/private/TemplateLayout.php | 3 ++- lib/private/User/User.php | 3 ++- lib/private/legacy/OC_App.php | 3 ++- lib/private/legacy/OC_User.php | 3 ++- tests/Core/Command/Apps/AppsEnableTest.php | 3 ++- tests/lib/AppTest.php | 5 +++-- tests/lib/Files/ViewTest.php | 3 ++- tests/lib/Share/ShareTest.php | 2 +- .../lib/Share20/DefaultShareProviderTest.php | 6 ++--- tests/lib/SubAdminTest.php | 3 ++- 19 files changed, 51 insertions(+), 33 deletions(-) diff --git a/core/register_command.php b/core/register_command.php index d9e5dfcd775eb..8fa642ea4e48c 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -48,6 +48,8 @@ * along with this program. If not, see * */ + +use OCP\IGroupManager; use Psr\Log\LoggerInterface; $application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand()); @@ -73,7 +75,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) { $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager())); - $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager())); + $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->get(IGroupManager::class))); $application->add(new OC\Core\Command\App\Install()); $application->add(new OC\Core\Command\App\GetPath()); $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager())); @@ -141,7 +143,7 @@ $util = new \OC\Encryption\Util( $view, \OC::$server->getUserManager(), - \OC::$server->getGroupManager(), + \OC::$server->get(IGroupManager::class), \OC::$server->getConfig() ); $application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot( @@ -182,7 +184,7 @@ $application->add(\OC::$server->query(\OC\Core\Command\Preview\Repair::class)); $application->add(\OC::$server->query(\OC\Core\Command\Preview\ResetRenderedTexts::class)); - $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); + $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->get(IGroupManager::class))); $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager())); $application->add(new OC\Core\Command\User\Disable(\OC::$server->getUserManager())); $application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager())); @@ -190,18 +192,18 @@ $application->add(\OC::$server->get(\OC\Core\Command\User\Report::class)); $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->getAppManager())); $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig())); - $application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); - $application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); + $application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->get(IGroupManager::class))); + $application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->get(IGroupManager::class))); $application->add(new OC\Core\Command\User\SyncAccountDataCommand(\OC::$server->getUserManager(), \OC::$server->get(\OCP\Accounts\IAccountManager::class))); $application->add(\OC::$server->get(\OC\Core\Command\User\AuthTokens\Add::class)); $application->add(\OC::$server->get(\OC\Core\Command\User\AuthTokens\ListCommand::class)); $application->add(\OC::$server->get(\OC\Core\Command\User\AuthTokens\Delete::class)); - $application->add(new OC\Core\Command\Group\Add(\OC::$server->getGroupManager())); - $application->add(new OC\Core\Command\Group\Delete(\OC::$server->getGroupManager())); - $application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->getGroupManager())); - $application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); - $application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); + $application->add(new OC\Core\Command\Group\Add(\OC::$server->get(IGroupManager::class))); + $application->add(new OC\Core\Command\Group\Delete(\OC::$server->get(IGroupManager::class))); + $application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->get(IGroupManager::class))); + $application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->get(IGroupManager::class))); + $application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->get(IGroupManager::class))); $application->add(new OC\Core\Command\Group\Info(\OC::$server->get(\OCP\IGroupManager::class))); $application->add(new OC\Core\Command\SystemTag\ListCommand(\OC::$server->get(\OCP\SystemTag\ISystemTagManager::class))); diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index a012d1e8ea69f..5721a46c66d2f 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -63,6 +63,7 @@ use OCP\Group\ISubAdmin; use OCP\IConfig; use OCP\IDBConnection; +use OCP\IGroupManager; use OCP\IInitialStateService; use OCP\IL10N; use OCP\ILogger; @@ -253,7 +254,7 @@ public function __construct(string $appName, array $urlParams = [], ServerContai $server->get(LoggerInterface::class), $c->get('AppName'), $server->getUserSession()->isLoggedIn(), - $this->getUserId() !== null && $server->getGroupManager()->isAdmin($this->getUserId()), + $this->getUserId() !== null && $server->get(IGroupManager::class)->isAdmin($this->getUserId()), $server->getUserSession()->getUser() !== null && $server->query(ISubAdmin::class)->isSubAdmin($server->getUserSession()->getUser()), $server->getAppManager(), $server->getL10N('lib'), diff --git a/lib/private/Encryption/EncryptionWrapper.php b/lib/private/Encryption/EncryptionWrapper.php index 37264e8182355..c8dc262896961 100644 --- a/lib/private/Encryption/EncryptionWrapper.php +++ b/lib/private/Encryption/EncryptionWrapper.php @@ -30,6 +30,7 @@ use OC\Memcache\ArrayCache; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; +use OCP\IGroupManager; use Psr\Log\LoggerInterface; /** @@ -85,7 +86,7 @@ public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount) { $util = new Util( new View(), \OC::$server->getUserManager(), - \OC::$server->getGroupManager(), + \OC::$server->get(IGroupManager::class), \OC::$server->getConfig() ); $update = new Update( diff --git a/lib/private/Encryption/HookManager.php b/lib/private/Encryption/HookManager.php index 5081bcccf948d..823b386f19d9f 100644 --- a/lib/private/Encryption/HookManager.php +++ b/lib/private/Encryption/HookManager.php @@ -26,6 +26,7 @@ use OC\Files\Filesystem; use OC\Files\View; use OC\Files\SetupManager; +use OCP\IGroupManager; use Psr\Log\LoggerInterface; class HookManager { @@ -75,7 +76,7 @@ private static function getUpdate(?string $owner = null): Update { new Util( new View(), \OC::$server->getUserManager(), - \OC::$server->getGroupManager(), + \OC::$server->get(IGroupManager::class), \OC::$server->getConfig()), Filesystem::getMountManager(), \OC::$server->getEncryptionManager(), diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 05624a2423a22..421dd42b2a661 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -40,6 +40,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Collaboration\Resources\IManager; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IGroupManager; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; use OC\DB\Connection; @@ -198,7 +199,7 @@ public static function getRepairSteps(): array { new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)), new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()), - new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OCP\Server::get(ITimeFactory::class)), + new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->get(IGroupManager::class), \OC::$server->getNotificationManager(), \OCP\Server::get(ITimeFactory::class)), new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OCP\Server::get(IManager::class)), \OCP\Server::get(ResetGeneratedAvatarFlag::class), \OCP\Server::get(EncryptionLegacyCipher::class), @@ -223,7 +224,7 @@ public static function getRepairSteps(): array { */ public static function getExpensiveRepairSteps() { return [ - new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()), + new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->get(IGroupManager::class)), \OC::$server->get(ValidatePhoneNumber::class), ]; } diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 0993fe54f4708..0dedce265d5d6 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -59,6 +59,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\Defaults; use OCP\IGroup; +use OCP\IGroupManager; use OCP\IL10N; use OCP\Security\ISecureRandom; use Psr\Log\LoggerInterface; @@ -401,7 +402,7 @@ public function install($options) { $config->setSystemValue('updater.release.channel', $vendorData['channel']); } - $group = \OC::$server->getGroupManager()->createGroup('admin'); + $group = \OC::$server->get(IGroupManager::class)->createGroup('admin'); if ($group instanceof IGroup) { $group->addUser($user); } diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 8d14f293e5a1e..e34dc09014cf4 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -39,6 +39,7 @@ use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; +use OCP\IGroupManager; use OCP\Share\IShare; use Psr\Log\LoggerInterface; @@ -198,7 +199,7 @@ public static function getItemSharedWithUser(string $itemType, string $itemSourc $userObject = \OC::$server->getUserManager()->get($user); $groups = []; if ($userObject) { - $groups = \OC::$server->getGroupManager()->getUserGroupIds($userObject); + $groups = \OC::$server->get(IGroupManager::class)->getUserGroupIds($userObject); } if (!empty($groups)) { @@ -406,7 +407,7 @@ public static function getItems($itemType, ?string $item = null, ?int $shareType $user = \OC::$server->getUserManager()->get($shareWith); $groups = []; if ($user) { - $groups = \OC::$server->getGroupManager()->getUserGroupIds($user); + $groups = \OC::$server->get(IGroupManager::class)->getUserGroupIds($user); } if (!empty($groups)) { $qb->orWhere($qb->expr()->andX( diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 8c01d6609155c..12136cefc1055 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -43,6 +43,7 @@ use OCA\Talk\Share\RoomShareProvider; use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IGroupManager; use OCP\IServerContainer; use OCP\Share\IManager; use OCP\Share\IProviderFactory; @@ -98,7 +99,7 @@ protected function defaultShareProvider() { $this->defaultProvider = new DefaultShareProvider( $this->serverContainer->getDatabaseConnection(), $this->serverContainer->getUserManager(), - $this->serverContainer->getGroupManager(), + $this->serverContainer->get(IGroupManager::class), $this->serverContainer->getLazyRootFolder(), $this->serverContainer->getMailer(), $this->serverContainer->query(Defaults::class), diff --git a/lib/private/SystemTag/ManagerFactory.php b/lib/private/SystemTag/ManagerFactory.php index 6670922407e37..2358ffb198bc8 100644 --- a/lib/private/SystemTag/ManagerFactory.php +++ b/lib/private/SystemTag/ManagerFactory.php @@ -27,6 +27,7 @@ namespace OC\SystemTag; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IGroupManager; use OCP\IServerContainer; use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\ISystemTagManagerFactory; @@ -64,7 +65,7 @@ public function __construct(IServerContainer $serverContainer) { public function getManager(): ISystemTagManager { return new SystemTagManager( $this->serverContainer->getDatabaseConnection(), - $this->serverContainer->getGroupManager(), + $this->serverContainer->get(IGroupManager::class), $this->serverContainer->get(IEventDispatcher::class), ); } diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 658a85152bf49..49476e7f6b204 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -50,6 +50,7 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\Defaults; use OCP\IConfig; +use OCP\IGroupManager; use OCP\IInitialStateService; use OCP\INavigationManager; use OCP\IUserSession; @@ -231,7 +232,7 @@ public function __construct($renderAs, $appId = '') { \OC::$server->getSession(), \OC::$server->getUserSession()->getUser(), $this->config, - \OC::$server->getGroupManager(), + \OC::$server->get(IGroupManager::class), \OC::$server->get(IniGetWrapper::class), \OC::$server->getURLGenerator(), \OC::$server->getCapabilitiesManager(), diff --git a/lib/private/User/User.php b/lib/private/User/User.php index d1185e17aef42..63cd1849daef5 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -45,6 +45,7 @@ use OCP\Group\Events\UserRemovedEvent; use OCP\IAvatarManager; use OCP\IConfig; +use OCP\IGroupManager; use OCP\IImage; use OCP\IURLGenerator; use OCP\IUser; @@ -277,7 +278,7 @@ public function delete() { if ($result) { // FIXME: Feels like an hack - suggestions? - $groupManager = \OC::$server->getGroupManager(); + $groupManager = \OC::$server->get(IGroupManager::class); // We have to delete the user from all groups foreach ($groupManager->getUserGroupIds($this) as $groupId) { $group = $groupManager->get($groupId); diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index ac449a62a4ffb..5113b1f26945e 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -56,6 +56,7 @@ use OCP\App\ManagerEvent; use OCP\Authentication\IAlternativeLogin; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IGroupManager; use OCP\ILogger; use OC\AppFramework\Bootstrap\Coordinator; use OC\App\DependencyAnalyzer; @@ -266,7 +267,7 @@ public function enable(string $appId, $appManager = \OC::$server->getAppManager(); if ($groups !== []) { - $groupManager = \OC::$server->getGroupManager(); + $groupManager = \OC::$server->get(IGroupManager::class); $groupsList = []; foreach ($groups as $group) { $groupItem = $groupManager->get($group); diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php index caa4f5dca6512..e58a44b207aab 100644 --- a/lib/private/legacy/OC_User.php +++ b/lib/private/legacy/OC_User.php @@ -38,6 +38,7 @@ use OC\User\LoginException; use OCP\EventDispatcher\IEventDispatcher; +use OCP\IGroupManager; use OCP\ILogger; use OCP\IUserManager; use OCP\User\Events\BeforeUserLoggedInEvent; @@ -323,7 +324,7 @@ public static function getLogoutUrl(\OCP\IURLGenerator $urlGenerator) { * @return bool */ public static function isAdminUser($uid) { - $group = \OC::$server->getGroupManager()->get('admin'); + $group = \OC::$server->get(IGroupManager::class)->get('admin'); $user = \OC::$server->getUserManager()->get($uid); if ($group && $user && $group->inGroup($user) && self::$incognitoMode === false) { return true; diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php index 6e5774641038e..d40d562017e70 100644 --- a/tests/Core/Command/Apps/AppsEnableTest.php +++ b/tests/Core/Command/Apps/AppsEnableTest.php @@ -24,6 +24,7 @@ namespace Tests\Core\Command\Config; use OC\Core\Command\App\Enable; +use OCP\IGroupManager; use Symfony\Component\Console\Tester\CommandTester; use Test\TestCase; @@ -41,7 +42,7 @@ protected function setUp(): void { $command = new Enable( \OC::$server->getAppManager(), - \OC::$server->getGroupManager() + \OC::$server->get(IGroupManager::class) ); $this->commandTester = new CommandTester($command); diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 12fbdb011d902..52316114382dd 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -14,6 +14,7 @@ use OC\AppConfig; use OCP\EventDispatcher\IEventDispatcher; use OCP\IAppConfig; +use OCP\IGroupManager; use Psr\Log\LoggerInterface; /** @@ -459,7 +460,7 @@ public function appConfigValuesProvider() { */ public function testEnabledApps($user, $expectedApps, $forceAll) { $userManager = \OC::$server->getUserManager(); - $groupManager = \OC::$server->getGroupManager(); + $groupManager = \OC::$server->get(IGroupManager::class); $user1 = $userManager->createUser(self::TEST_USER1, self::TEST_USER1); $user2 = $userManager->createUser(self::TEST_USER2, self::TEST_USER2); $user3 = $userManager->createUser(self::TEST_USER3, self::TEST_USER3); @@ -558,7 +559,7 @@ private function registerAppConfig(AppConfig $appConfig) { \OC::$server->getUserSession(), \OC::$server->getConfig(), $appConfig, - \OC::$server->getGroupManager(), + \OC::$server->get(IGroupManager::class), \OC::$server->getMemCacheFactory(), \OC::$server->get(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class) diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 2bf483df7d7f3..3ecf1efea7f5a 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -23,6 +23,7 @@ use OCP\Files\Mount\IMountManager; use OCP\Files\Storage\IStorage; use OCP\IDBConnection; +use OCP\IGroupManager; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; use OCP\Share\IShare; @@ -99,7 +100,7 @@ protected function setUp(): void { //login $userManager = \OC::$server->getUserManager(); - $groupManager = \OC::$server->getGroupManager(); + $groupManager = \OC::$server->get(IGroupManager::class); $this->user = 'test'; $this->userObject = $userManager->createUser('test', 'test'); diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php index 35dc00739f665..6a6bc34afa7e2 100644 --- a/tests/lib/Share/ShareTest.php +++ b/tests/lib/Share/ShareTest.php @@ -61,7 +61,7 @@ class ShareTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->groupManager = \OC::$server->getGroupManager(); + $this->groupManager = \OC::$server->get(IGroupManager::class); $this->userManager = \OC::$server->getUserManager(); $this->userManager->clearBackends(); diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index 0a6f106a5dba9..a6abadcb9fe33 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -2512,7 +2512,7 @@ public function testUserDeletedFromGroup($group, $user, $toDelete) { public function testGetSharesInFolder() { $userManager = \OC::$server->getUserManager(); - $groupManager = \OC::$server->getGroupManager(); + $groupManager = \OC::$server->get(IGroupManager::class); $rootFolder = \OC::$server->getRootFolder(); $provider = new DefaultShareProvider( @@ -2610,7 +2610,7 @@ public function testGetSharesInFolder() { public function testGetAccessListNoCurrentAccessRequired() { $userManager = \OC::$server->getUserManager(); - $groupManager = \OC::$server->getGroupManager(); + $groupManager = \OC::$server->get(IGroupManager::class); $rootFolder = \OC::$server->getRootFolder(); $provider = new DefaultShareProvider( @@ -2706,7 +2706,7 @@ public function testGetAccessListNoCurrentAccessRequired() { public function testGetAccessListCurrentAccessRequired() { $userManager = \OC::$server->getUserManager(); - $groupManager = \OC::$server->getGroupManager(); + $groupManager = \OC::$server->get(IGroupManager::class); $rootFolder = \OC::$server->getRootFolder(); $provider = new DefaultShareProvider( diff --git a/tests/lib/SubAdminTest.php b/tests/lib/SubAdminTest.php index 647141a73f787..c98d26cec7147 100644 --- a/tests/lib/SubAdminTest.php +++ b/tests/lib/SubAdminTest.php @@ -24,6 +24,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Group\Events\SubAdminAddedEvent; use OCP\Group\Events\SubAdminRemovedEvent; +use OCP\IGroupManager; /** * @group DB @@ -54,7 +55,7 @@ protected function setUp(): void { $this->groups = []; $this->userManager = \OC::$server->getUserManager(); - $this->groupManager = \OC::$server->getGroupManager(); + $this->groupManager = \OC::$server->get(IGroupManager::class); $this->dbConn = \OC::$server->getDatabaseConnection(); $this->eventDispatcher = \OC::$server->get(IEventDispatcher::class);