summaryrefslogtreecommitdiffstats
path: root/apps/federation
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-07-28 14:54:08 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-08-01 10:07:53 +0200
commit9c9cb1a6dbb8cc57923a6516bea451454a662622 (patch)
tree2940bd7c90e4b7b647644be12af5d36e108595b7 /apps/federation
parent06b9e580814cffdc2567686cd9aac80e7418bc26 (diff)
downloadnextcloud-server-9c9cb1a6dbb8cc57923a6516bea451454a662622.tar.gz
nextcloud-server-9c9cb1a6dbb8cc57923a6516bea451454a662622.zip
cleanup constructors
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federation')
-rw-r--r--apps/federation/lib/BackgroundJob/GetSharedSecret.php43
-rw-r--r--apps/federation/lib/BackgroundJob/RequestSharedSecret.php43
2 files changed, 33 insertions, 53 deletions
diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
index 761ad951e73..d679fcb6aa3 100644
--- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
@@ -34,6 +34,7 @@ use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http;
use OCP\BackgroundJob\IJobList;
use OCP\Http\Client\IClient;
+use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\ILogger;
use OCP\IURLGenerator;
@@ -82,7 +83,7 @@ class GetSharedSecret extends Job{
/**
* RequestSharedSecret constructor.
*
- * @param IClient $httpClient
+ * @param IClientService $httpClientService
* @param IURLGenerator $urlGenerator
* @param IJobList $jobList
* @param TrustedServers $trustedServers
@@ -91,33 +92,21 @@ class GetSharedSecret extends Job{
* @param IDiscoveryService $ocsDiscoveryService
*/
public function __construct(
- IClient $httpClient = null,
- IURLGenerator $urlGenerator = null,
- IJobList $jobList = null,
- TrustedServers $trustedServers = null,
- ILogger $logger = null,
- DbHandler $dbHandler = null,
- IDiscoveryService $ocsDiscoveryService = null
+ IClientService $httpClientService,
+ IURLGenerator $urlGenerator,
+ IJobList $jobList,
+ TrustedServers $trustedServers,
+ ILogger $logger,
+ DbHandler $dbHandler,
+ IDiscoveryService $ocsDiscoveryService
) {
- $this->logger = $logger ? $logger : \OC::$server->getLogger();
- $this->httpClient = $httpClient ? $httpClient : \OC::$server->getHTTPClientService()->newClient();
- $this->jobList = $jobList ? $jobList : \OC::$server->getJobList();
- $this->urlGenerator = $urlGenerator ? $urlGenerator : \OC::$server->getURLGenerator();
- $this->dbHandler = $dbHandler ? $dbHandler : new DbHandler(\OC::$server->getDatabaseConnection(), \OC::$server->getL10N('federation'));
- $this->ocsDiscoveryService = $ocsDiscoveryService ? $ocsDiscoveryService : \OC::$server->query(\OCP\OCS\IDiscoveryService::class);
- if ($trustedServers) {
- $this->trustedServers = $trustedServers;
- } else {
- $this->trustedServers = new TrustedServers(
- $this->dbHandler,
- \OC::$server->getHTTPClientService(),
- $this->logger,
- $this->jobList,
- \OC::$server->getSecureRandom(),
- \OC::$server->getConfig(),
- \OC::$server->getEventDispatcher()
- );
- }
+ $this->logger = $logger;
+ $this->httpClient = $httpClientService->newClient();
+ $this->jobList = $jobList;
+ $this->urlGenerator = $urlGenerator;
+ $this->dbHandler = $dbHandler;
+ $this->ocsDiscoveryService = $ocsDiscoveryService;
+ $this->trustedServers = $trustedServers;
}
/**
diff --git a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
index 8a4bd8c4996..0180c0dbf55 100644
--- a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
@@ -35,6 +35,7 @@ use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http;
use OCP\BackgroundJob\IJobList;
use OCP\Http\Client\IClient;
+use OCP\Http\Client\IClientService;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\OCS\IDiscoveryService;
@@ -82,40 +83,30 @@ class RequestSharedSecret extends Job {
/**
* RequestSharedSecret constructor.
*
- * @param IClient $httpClient
+ * @param IClientService $httpClientService
* @param IURLGenerator $urlGenerator
* @param IJobList $jobList
* @param TrustedServers $trustedServers
* @param DbHandler $dbHandler
* @param IDiscoveryService $ocsDiscoveryService
+ * @param ILogger $logger
*/
public function __construct(
- IClient $httpClient = null,
- IURLGenerator $urlGenerator = null,
- IJobList $jobList = null,
- TrustedServers $trustedServers = null,
- DbHandler $dbHandler = null,
- IDiscoveryService $ocsDiscoveryService = null
+ IClientService $httpClientService,
+ IURLGenerator $urlGenerator,
+ IJobList $jobList,
+ TrustedServers $trustedServers,
+ DbHandler $dbHandler,
+ IDiscoveryService $ocsDiscoveryService,
+ ILogger $logger
) {
- $this->httpClient = $httpClient ? $httpClient : \OC::$server->getHTTPClientService()->newClient();
- $this->jobList = $jobList ? $jobList : \OC::$server->getJobList();
- $this->urlGenerator = $urlGenerator ? $urlGenerator : \OC::$server->getURLGenerator();
- $this->dbHandler = $dbHandler ? $dbHandler : new DbHandler(\OC::$server->getDatabaseConnection(), \OC::$server->getL10N('federation'));
- $this->logger = \OC::$server->getLogger();
- $this->ocsDiscoveryService = $ocsDiscoveryService ? $ocsDiscoveryService : \OC::$server->query(\OCP\OCS\IDiscoveryService::class);
- if ($trustedServers) {
- $this->trustedServers = $trustedServers;
- } else {
- $this->trustedServers = new TrustedServers(
- $this->dbHandler,
- \OC::$server->getHTTPClientService(),
- $this->logger,
- $this->jobList,
- \OC::$server->getSecureRandom(),
- \OC::$server->getConfig(),
- \OC::$server->getEventDispatcher()
- );
- }
+ $this->httpClient = $httpClientService->newClient();
+ $this->jobList = $jobList;
+ $this->urlGenerator = $urlGenerator;
+ $this->dbHandler = $dbHandler;
+ $this->logger = $logger;
+ $this->ocsDiscoveryService = $ocsDiscoveryService;
+ $this->trustedServers = $trustedServers;
}