diff options
author | Andrew Summers <18727110+summersab@users.noreply.github.com> | 2023-08-29 17:07:38 -0500 |
---|---|---|
committer | Andrew Summers <18727110+summersab@users.noreply.github.com> | 2023-08-29 21:32:58 -0500 |
commit | 6b09a79227a5dc98aa4620c6e5e15b610a06c806 (patch) | |
tree | d6bf73c77bcd6fee4374bdfe93aae7b3d9af5f78 | |
parent | 9d1547f59d53b46ba401ddf0e7f4c6e4f067004e (diff) | |
download | nextcloud-server-6b09a79227a5dc98aa4620c6e5e15b610a06c806.tar.gz nextcloud-server-6b09a79227a5dc98aa4620c6e5e15b610a06c806.zip |
Refactor `OC\Server::getShareManager`
Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com>
-rw-r--r-- | lib/private/Share20/Hooks.php | 6 | ||||
-rw-r--r-- | lib/private/Template/JSConfigHelper.php | 3 | ||||
-rw-r--r-- | lib/public/Util.php | 5 | ||||
-rw-r--r-- | tests/lib/Files/ViewTest.php | 7 | ||||
-rw-r--r-- | tests/lib/Share20/DefaultShareProviderTest.php | 7 | ||||
-rw-r--r-- | tests/lib/Share20/LegacyHooksTest.php | 3 |
6 files changed, 19 insertions, 12 deletions
diff --git a/lib/private/Share20/Hooks.php b/lib/private/Share20/Hooks.php index ae08b20fde6..2ab328b6bd9 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 7b6d0a6a346..9cf0838e43a 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\ILogger; use OCP\IUser; +use OCP\Share\IManager as IShareManager; use OCP\User\Backend\IPasswordConfirmationBackend; use OCP\Util; @@ -260,7 +261,7 @@ class JSConfigHelper { '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 bff8038b3dd..34ccc61074f 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -48,6 +48,7 @@ namespace OCP; use OC\AppScriptDependency; use OC\AppScriptSort; +use OCP\Share\IManager as IShareManager; use bantu\IniGetWrapper\IniGetWrapper; use Psr\Container\ContainerExceptionInterface; @@ -127,11 +128,11 @@ class Util { * * @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(IShareManager::class); } $user = \OC::$server->getUserSession()->getUser(); diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 2bf483df7d7..a0323293605 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -25,6 +25,7 @@ use OCP\Files\Storage\IStorage; 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; @@ -296,7 +297,7 @@ class ViewTest extends \Test\TestCase { */ public function testRemoveSharePermissionWhenSharingDisabledForUser($excludeGroups, $excludeGroupsList, $expectedShareable) { // Reset sharing disabled for users cache - self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]); + self::invokePrivate(\OC::$server->get(IShareManager::class), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]); $config = \OC::$server->getConfig(); $oldExcludeGroupsFlag = $config->getAppValue('core', 'shareapi_exclude_groups', 'no'); @@ -321,7 +322,7 @@ class ViewTest extends \Test\TestCase { $config->setAppValue('core', 'shareapi_exclude_groups_list', $oldExcludeGroupsList); // Reset sharing disabled for users cache - self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]); + self::invokePrivate(\OC::$server->get(IShareManager::class), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]); } public function testCacheIncompleteFolder() { @@ -1683,7 +1684,7 @@ class ViewTest extends \Test\TestCase { $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 0a6f106a5db..08e7d1aa274 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -39,6 +39,7 @@ use OCP\IUser; 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; @@ -2540,7 +2541,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $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()) @@ -2644,7 +2645,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $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()) @@ -2740,7 +2741,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $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 728f320ea9e..239b3c91ca1 100644 --- a/tests/lib/Share20/LegacyHooksTest.php +++ b/tests/lib/Share20/LegacyHooksTest.php @@ -35,6 +35,7 @@ use OCP\Share\Events\BeforeShareDeletedEvent; 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 @@ class LegacyHooksTest extends TestCase { $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() { |