Skip to content

Commit

Permalink
Merge branch 'master' into refactor/OC-Server-getL10NFactory
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv authored May 30, 2024
2 parents 0963336 + be4e97d commit 4d9199f
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 23 deletions.
3 changes: 2 additions & 1 deletion apps/dav/lib/Avatars/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
namespace OCA\DAV\Avatars;

use OCP\IAvatarManager;
use Sabre\DAVACL\AbstractPrincipalCollection;

class RootCollection extends AbstractPrincipalCollection {
Expand All @@ -21,7 +22,7 @@ class RootCollection extends AbstractPrincipalCollection {
* @return AvatarHome
*/
public function getChildForPrincipal(array $principalInfo) {
$avatarManager = \OC::$server->getAvatarManager();
$avatarManager = \OC::$server->get(IAvatarManager::class);
return new AvatarHome($principalInfo, $avatarManager);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Jobs/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function setArgument($argument) {
if (isset($argument['avatarManager'])) {
$this->avatarManager = $argument['avatarManager'];
} else {
$this->avatarManager = \OC::$server->getAvatarManager();
$this->avatarManager = \OC::$server->get(IAvatarManager::class);
}

if (isset($argument['dbc'])) {
Expand Down
3 changes: 2 additions & 1 deletion apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use OCA\User_LDAP\LDAP;
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\UserPluginManager;
use OCP\IAvatarManager;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -124,7 +125,7 @@ protected function initUserManager() {
\OC::$server->getConfig(),
new FilesystemHelper(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getAvatarManager(),
\OC::$server->get(IAvatarManager::class),
new \OCP\Image(),
\OC::$server->getUserManager(),
\OC::$server->getNotificationManager(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use OCA\User_LDAP\User\User;
use OCA\User_LDAP\User_LDAP;
use OCA\User_LDAP\UserPluginManager;
use OCP\IAvatarManager;
use OCP\Image;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -78,8 +79,8 @@ private function execFetchTest($dn, $username, $image) {
\OC_Util::setupFS($username);
\OC::$server->getUserFolder($username);
\OC::$server->getConfig()->deleteUserValue($username, 'user_ldap', User::USER_PREFKEY_LASTREFRESH);
if (\OC::$server->getAvatarManager()->getAvatar($username)->exists()) {
\OC::$server->getAvatarManager()->getAvatar($username)->remove();
if (\OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists()) {
\OC::$server->get(IAvatarManager::class)->getAvatar($username)->remove();
}

// finally attempt to get the avatar set
Expand All @@ -99,7 +100,7 @@ protected function case1() {

$this->execFetchTest($dn, $username, $image);

return \OC::$server->getAvatarManager()->getAvatar($username)->exists();
return \OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists();
}

/**
Expand All @@ -116,7 +117,7 @@ protected function case2() {

$this->execFetchTest($dn, $username, $image);

return !\OC::$server->getAvatarManager()->getAvatar($username)->exists();
return !\OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists();
}

/**
Expand All @@ -136,7 +137,7 @@ protected function initUserManager() {
\OC::$server->getConfig(),
new FilesystemHelper(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getAvatarManager(),
\OC::$server->get(IAvatarManager::class),
new Image(),
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager(),
Expand Down
5 changes: 3 additions & 2 deletions build/integration/features/bootstrap/RemoteContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Behat\Behat\Context\Context;
use OCP\Http\Client\IClientService;
use PHPUnit\Framework\Assert;

require __DIR__ . '/../../vendor/autoload.php';
Expand Down Expand Up @@ -31,7 +32,7 @@ public function __construct($remote) {
}

protected function getApiClient() {
return new \OC\Remote\Api\OCS($this->remoteInstance, $this->credentails, \OC::$server->getHTTPClientService());
return new \OC\Remote\Api\OCS($this->remoteInstance, $this->credentails, \OC::$server->get(IClientService::class));
}

/**
Expand All @@ -47,7 +48,7 @@ public function selectRemoteInstance($remoteServer) {
}
$this->lastException = null;
try {
$this->remoteInstance = new \OC\Remote\Instance($baseUri, \OC::$server->getMemCacheFactory()->createLocal(), \OC::$server->getHTTPClientService());
$this->remoteInstance = new \OC\Remote\Instance($baseUri, \OC::$server->getMemCacheFactory()->createLocal(), \OC::$server->get(IClientService::class));
// trigger the status request
$this->remoteInstance->getProtocol();
} catch (\Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class DAV extends Common {
*/
public function __construct($params) {
$this->statCache = new ArrayCache();
$this->httpClientService = \OC::$server->getHTTPClientService();
$this->httpClientService = \OC::$server->get(IClientService::class);
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
$host = $params['host'];
//remove leading http[s], will be generated in createBaseUri()
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* Example usage:
*
* $mailer = \OC::$server->getMailer();
* $mailer = \OC::$server->get(\OCP\Mail\IMailer::class);
* $message = $mailer->createMessage();
* $message->setSubject('Your Subject');
* $message->setFrom(array('[email protected]' => 'ownCloud Notifier'));
Expand Down
8 changes: 5 additions & 3 deletions lib/private/Share20/ProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Files\IRootFolder;
use OCP\Http\Client\IClientService;
use OCP\IServerContainer;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Security\IHasher;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
Expand Down Expand Up @@ -79,7 +81,7 @@ protected function defaultShareProvider() {
$this->serverContainer->getUserManager(),
$this->serverContainer->getGroupManager(),
$this->serverContainer->get(IRootFolder::class),
$this->serverContainer->getMailer(),
$this->serverContainer->get(IMailer::class),
$this->serverContainer->query(Defaults::class),
$this->serverContainer->get(IFactory::class),
$this->serverContainer->getURLGenerator(),
Expand Down Expand Up @@ -116,7 +118,7 @@ protected function federatedShareProvider() {
);
$notifications = new Notifications(
$addressHandler,
$this->serverContainer->getHTTPClientService(),
$this->serverContainer->get(IClientService::class),
$this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
$this->serverContainer->getJobList(),
\OC::$server->getCloudFederationProviderManager(),
Expand Down Expand Up @@ -172,7 +174,7 @@ protected function getShareByMailProvider() {
$this->serverContainer->get(IRootFolder::class),
$this->serverContainer->getL10N('sharebymail'),
$this->serverContainer->get(LoggerInterface::class),
$this->serverContainer->getMailer(),
$this->serverContainer->get(IMailer::class),
$this->serverContainer->getURLGenerator(),
$this->serverContainer->getActivityManager(),
$settingsManager,
Expand Down
5 changes: 3 additions & 2 deletions lib/private/legacy/OC_Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager;
use OC\Files\SetupManager;
use OCP\Files\Template\ITemplateManager;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IURLGenerator;
Expand Down Expand Up @@ -878,7 +879,7 @@ public function isHtaccessWorking(\OCP\IConfig $config) {
// accessing the file via http
$url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName);
try {
$content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody();
$content = \OC::$server->get(IClientService::class)->newClient()->get($url)->getBody();
} catch (\Exception $e) {
$content = false;
}
Expand All @@ -890,7 +891,7 @@ public function isHtaccessWorking(\OCP\IConfig $config) {
}

try {
$fallbackContent = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody();
$fallbackContent = \OC::$server->get(IClientService::class)->newClient()->get($url)->getBody();
} catch (\Exception $e) {
$fallbackContent = false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Contacts/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface IManager {
* Following function shows how to search for contacts for the name and the email address.
*
* public static function getMatchingRecipient($term) {
* $cm = \OC::$server->getContactsManager();
* $cm = \OCP\Server::get(\OCP\Contacts\IManager::class);
* // The API is not active -> nothing to do
* if (!$cm->isEnabled()) {
* return array();
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Mail/IMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* Example usage:
*
* $mailer = \OC::$server->getMailer();
* $mailer = \OC::$server->get(\OCP\Mail\IMailer::class);
* $message = $mailer->createMessage();
* $message->setSubject('Your Subject');
* $message->setFrom(['[email protected]' => 'Nextcloud Notifier']);
Expand Down
3 changes: 2 additions & 1 deletion lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OC\AppScriptDependency;
use OC\AppScriptSort;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Share\IManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -303,7 +304,7 @@ public static function getDefaultEmailAddress(string $user_part): string {
$host_name = $config->getSystemValueString('mail_domain', $host_name);
$defaultEmailAddress = $user_part.'@'.$host_name;

$mailer = \OC::$server->getMailer();
$mailer = \OC::$server->get(IMailer::class);
if ($mailer->validateMailAddress($defaultEmailAddress)) {
return $defaultEmailAddress;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function setUp(): void {
$config->setSystemValue('appstoreenabled', true);
$installer = new Installer(
\OC::$server->get(AppFetcher::class),
\OC::$server->getHTTPClientService(),
\OC::$server->get(IClientService::class),
\OC::$server->getTempManager(),
\OC::$server->get(LoggerInterface::class),
$config,
Expand All @@ -74,7 +74,7 @@ protected function getInstaller() {
protected function tearDown(): void {
$installer = new Installer(
\OC::$server->get(AppFetcher::class),
\OC::$server->getHTTPClientService(),
\OC::$server->get(IClientService::class),
\OC::$server->getTempManager(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getConfig(),
Expand All @@ -98,7 +98,7 @@ public function testInstallApp() {
// Install app
$installer = new Installer(
\OC::$server->get(AppFetcher::class),
\OC::$server->getHTTPClientService(),
\OC::$server->get(IClientService::class),
\OC::$server->getTempManager(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getConfig(),
Expand Down

0 comments on commit 4d9199f

Please sign in to comment.