Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Replace \OC::$server->get with \OCP\Server::get #3204

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Command/Trashbin/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Cleanup extends Base {
public function __construct(FolderManager $folderManager, IRootFolder $rootFolder) {
parent::__construct();
if (\OC::$server->getAppManager()->isEnabledForUser('files_trashbin')) {
$this->trashBackend = \OC::$server->get(TrashBackend::class);
$this->trashBackend = \OCP\Server::get(TrashBackend::class);
$this->folderManager = $folderManager;
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Folder/FolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
private function getManageAcl(array $mappings): array {
return array_filter(array_map(function (array $entry): ?array {
if ($entry['mapping_type'] === 'user') {
$user = \OC::$server->get(IUserManager::class)->get($entry['mapping_id']);
$user = \OCP\Server::get(IUserManager::class)->get($entry['mapping_id']);
if ($user === null) {
return null;
}
Expand All @@ -240,14 +240,14 @@
'displayname' => (string)$user->getDisplayName()
];
}
$group = \OC::$server->get(IGroupManager::class)->get($entry['mapping_id']);
$group = \OCP\Server::get(IGroupManager::class)->get($entry['mapping_id']);
if ($group === null) {
return [];
}
return [
'type' => 'group',
'id' => (string)$group->getGID(),

Check failure on line 249 in lib/Folder/FolderManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

RedundantCast

lib/Folder/FolderManager.php:249:13: RedundantCast: Redundant cast to string (see https://psalm.dev/262)
'displayname' => (string)$group->getDisplayName()

Check failure on line 250 in lib/Folder/FolderManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

RedundantCast

lib/Folder/FolderManager.php:250:22: RedundantCast: Redundant cast to string (see https://psalm.dev/262)
];
}, $mappings), function (?array $element): bool {
return $element !== null;
Expand Down Expand Up @@ -304,7 +304,7 @@

public function getFolderByPath(string $path): int {
/** @var Node $node */
$node = \OC::$server->get(IRootFolder::class)->get($path);
$node = \OCP\Server::get(IRootFolder::class)->get($path);
/** @var GroupMountPoint $mountPoint */
$mountPoint = $node->getMountPoint();
return $mountPoint->getFolderId();
Expand Down Expand Up @@ -412,7 +412,7 @@

// Call private server api
if (class_exists('\OC\Settings\AuthorizedGroupMapper')) {
$authorizedGroupMapper = \OC::$server->get('\OC\Settings\AuthorizedGroupMapper');
$authorizedGroupMapper = \OCP\Server::get('\OC\Settings\AuthorizedGroupMapper');
$settingClasses = $authorizedGroupMapper->findAllClassesForUser($user);
if (in_array('OCA\GroupFolders\Settings\Admin', $settingClasses, true)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mount/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private function getCurrentUID(): ?string {
try {
// wopi requests are not logged in, instead we need to get the editor user from the access token
if (strpos($this->request->getRawPathInfo(), 'apps/richdocuments/wopi') && class_exists('OCA\Richdocuments\Db\WopiMapper')) {
$wopiMapper = \OC::$server->get('OCA\Richdocuments\Db\WopiMapper');
$wopiMapper = \OCP\Server::get('OCA\Richdocuments\Db\WopiMapper');
$token = $this->request->getParam('access_token');
if ($token) {
$wopi = $wopiMapper->getPathForToken($token);
Expand Down
14 changes: 7 additions & 7 deletions tests/Trash/TrashBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ public function setUp(): void {
$this->normalUser = $this->createUser('normal', 'test');

/** @var Database $groupBackend */
$groupBackend = \OC::$server->get(Database::class);
$groupBackend = \OCP\Server::get(Database::class);
$groupBackend->createGroup('gf_manager');
$groupBackend->createGroup('gf_normal');
$groupBackend->addToGroup('manager', 'gf_manager');
$groupBackend->addToGroup('normal', 'gf_normal');

$this->trashBackend = \OC::$server->get(TrashBackend::class);
$this->folderManager = \OC::$server->get(FolderManager::class);
$this->trashBackend = \OCP\Server::get(TrashBackend::class);
$this->folderManager = \OCP\Server::get(FolderManager::class);
/** @var ACLManagerFactory $aclManagerFactory */
$aclManagerFactory = \OC::$server->get(ACLManagerFactory::class);
$aclManagerFactory = \OCP\Server::get(ACLManagerFactory::class);
$this->aclManager = $aclManagerFactory->getACLManager($this->managerUser);
$this->ruleManager = \OC::$server->get(RuleManager::class);
$this->ruleManager = \OCP\Server::get(RuleManager::class);

$this->folderId = $this->folderManager->createFolder($this->folderName);
$this->folderManager->addApplicableGroup($this->folderId, 'gf_manager');
Expand All @@ -70,7 +70,7 @@ public function setUp(): void {
$this->folderManager->setManageACL($this->folderId, 'user', 'manager', true);

/** @var IRootFolder $rootFolder */
$rootFolder = \OC::$server->get(IRootFolder::class);
$rootFolder = \OCP\Server::get(IRootFolder::class);

$this->managerUserFolder = $rootFolder->getUserFolder('manager');
$this->normalUserFolder = $rootFolder->getUserFolder('normal');
Expand All @@ -90,7 +90,7 @@ protected function tearDown(): void {
$this->folderManager->removeFolder($this->folderId);

/** @var SetupManager $setupManager */
$setupManager = \OC::$server->get(SetupManager::class);
$setupManager = \OCP\Server::get(SetupManager::class);
$setupManager->tearDown();
parent::tearDown();
}
Expand Down
Loading