diff --git a/lib/private/Share20/Hooks.php b/lib/private/Share20/Hooks.php index ae08b20fde6b7..2ab328b6bd9d9 100644 --- a/lib/private/Share20/Hooks.php +++ b/lib/private/Share20/Hooks.php @@ -21,12 +21,14 @@ */ namespace OC\Share20; +use OCP\Share\IManager as IShareManager; + class Hooks { public static function post_deleteUser($arguments) { - \OC::$server->getShareManager()->userDeleted($arguments['uid']); + \OC::$server->get(IShareManager::class)->userDeleted($arguments['uid']); } public static function post_deleteGroup($arguments) { - \OC::$server->getShareManager()->groupDeleted($arguments['gid']); + \OC::$server->get(IShareManager::class)->groupDeleted($arguments['gid']); } } diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index 8cba93f1f4e69..d2cd536fa9f90 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -49,6 +49,7 @@ use OCP\ISession; use OCP\IURLGenerator; use OCP\IUser; +use OCP\Share\IManager as IShareManager; use OCP\User\Backend\IPasswordConfirmationBackend; use OCP\Util; @@ -261,7 +262,7 @@ public function getConfig(): string { 'resharingAllowed' => Share::isResharingAllowed(), 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, 'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'), - 'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(), + 'allowGroupSharing' => \OC::$server->get(IShareManager::class)->allowGroupSharing(), 'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled, 'defaultInternalExpireDate' => $defaultInternalExpireDate, 'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced, diff --git a/lib/public/Util.php b/lib/public/Util.php index e3f394c1ca9d5..11229567188c0 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -110,11 +110,11 @@ public static function getChannel() { * * @return boolean * @since 7.0.0 - * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser + * @deprecated 9.1.0 Use \OC::$server->get(\OCP\Share\IManager::class)->sharingDisabledForUser */ public static function isSharingDisabledForUser() { if (self::$shareManager === null) { - self::$shareManager = \OC::$server->getShareManager(); + self::$shareManager = \OC::$server->get(IManager::class); } $user = \OC::$server->getUserSession()->getUser(); diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index b9dd49d71fe28..818c69ed355c0 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -26,6 +26,7 @@ use OCP\IDBConnection; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; +use OCP\Share\IManager as IShareManager; use OCP\Share\IShare; use OCP\Util; use Test\HookHelper; @@ -1684,7 +1685,7 @@ public function testMoveMountPointIntoSharedFolder() { $userFolder = \OC::$server->getUserFolder($this->user); $shareDir = $userFolder->get('shareddir'); - $shareManager = \OC::$server->getShareManager(); + $shareManager = \OC::$server->get(IShareManager::class); $share = $shareManager->newShare(); $share->setSharedWith('test2') ->setSharedBy($this->user) diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index b658e20d83788..0433da35edf91 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -39,6 +39,7 @@ use OCP\IUserManager; use OCP\L10N\IFactory; use OCP\Mail\IMailer; +use OCP\Share\IManager as IShareManager; use OCP\Share\IShare; use PHPUnit\Framework\MockObject\MockObject; @@ -2541,7 +2542,7 @@ public function testGetSharesInFolder() { $file1 = $folder1->newFile('bar'); $folder2 = $folder1->newFolder('baz'); - $shareManager = \OC::$server->getShareManager(); + $shareManager = \OC::$server->get(IShareManager::class); $share1 = $shareManager->newShare(); $share1->setNode($folder1) ->setSharedBy($u1->getUID()) @@ -2645,7 +2646,7 @@ public function testGetAccessListNoCurrentAccessRequired() { $this->assertCount(0, $result['users']); $this->assertFalse($result['public']); - $shareManager = \OC::$server->getShareManager(); + $shareManager = \OC::$server->get(IShareManager::class); $share1 = $shareManager->newShare(); $share1->setNode($folder1) ->setSharedBy($u1->getUID()) @@ -2741,7 +2742,7 @@ public function testGetAccessListCurrentAccessRequired() { $this->assertCount(0, $result['users']); $this->assertFalse($result['public']); - $shareManager = \OC::$server->getShareManager(); + $shareManager = \OC::$server->get(IShareManager::class); $share1 = $shareManager->newShare(); $share1->setNode($folder1) ->setSharedBy($u1->getUID()) diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php index 728f320ea9e7b..239b3c91ca1d7 100644 --- a/tests/lib/Share20/LegacyHooksTest.php +++ b/tests/lib/Share20/LegacyHooksTest.php @@ -35,6 +35,7 @@ use OCP\Share\Events\ShareCreatedEvent; use OCP\Share\Events\ShareDeletedEvent; use OCP\Share\Events\ShareDeletedFromSelfEvent; +use OCP\Share\IManager as IShareManager; use OCP\Share\IShare; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -56,7 +57,7 @@ protected function setUp(): void { $logger = $this->createMock(LoggerInterface::class); $this->eventDispatcher = new \OC\EventDispatcher\EventDispatcher($symfonyDispatcher, \OC::$server->get(IServerContainer::class), $logger); $this->hooks = new LegacyHooks($this->eventDispatcher); - $this->manager = \OC::$server->getShareManager(); + $this->manager = \OC::$server->get(IShareManager::class); } public function testPreUnshare() {