aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-05-14 09:34:18 +0200
committerGitHub <noreply@github.com>2018-05-14 09:34:18 +0200
commit95592ff65c68a167cc8da6bfea022f3e3e2d25f7 (patch)
treed9e25ff406f269f17b39fb870b94658c93fc390b
parent68dc6a306ea99fbd62c9ab3ef645f513d8873983 (diff)
parentcd53498256c8d600821a55180c75564bcc63a364 (diff)
downloadnextcloud-server-95592ff65c68a167cc8da6bfea022f3e3e2d25f7.tar.gz
nextcloud-server-95592ff65c68a167cc8da6bfea022f3e3e2d25f7.zip
Merge pull request #9464 from nextcloud/fix/noid/version_expiration_DI
Use more magic DI in files_versions
-rw-r--r--apps/files_versions/lib/AppInfo/Application.php10
-rw-r--r--apps/files_versions/lib/BackgroundJob/ExpireVersions.php16
-rw-r--r--apps/files_versions/lib/Command/ExpireVersions.php8
-rw-r--r--apps/files_versions/lib/Storage.php2
4 files changed, 8 insertions, 28 deletions
diff --git a/apps/files_versions/lib/AppInfo/Application.php b/apps/files_versions/lib/AppInfo/Application.php
index 4431fbf51bf..be80f7d853b 100644
--- a/apps/files_versions/lib/AppInfo/Application.php
+++ b/apps/files_versions/lib/AppInfo/Application.php
@@ -41,16 +41,6 @@ class Application extends App {
$container->registerCapability(Capabilities::class);
/*
- * Register expiration
- */
- $container->registerService('Expiration', function($c) {
- return new Expiration(
- $c->query('ServerContainer')->getConfig(),
- $c->query(ITimeFactory::class)
- );
- });
-
- /*
* Register $principalBackend for the DAV collection
*/
$container->registerService('principalBackend', function () {
diff --git a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php
index d69e5bb87ce..47a1903a535 100644
--- a/apps/files_versions/lib/BackgroundJob/ExpireVersions.php
+++ b/apps/files_versions/lib/BackgroundJob/ExpireVersions.php
@@ -44,22 +44,12 @@ class ExpireVersions extends \OC\BackgroundJob\TimedJob {
*/
private $userManager;
- public function __construct(IUserManager $userManager = null, Expiration $expiration = null) {
+ public function __construct(IUserManager $userManager, Expiration $expiration) {
// Run once per 30 minutes
$this->setInterval(60 * 30);
- if (is_null($expiration) || is_null($userManager)) {
- $this->fixDIForJobs();
- } else {
- $this->expiration = $expiration;
- $this->userManager = $userManager;
- }
- }
-
- protected function fixDIForJobs() {
- $application = new Application();
- $this->expiration = $application->getContainer()->query('Expiration');
- $this->userManager = \OC::$server->getUserManager();
+ $this->expiration = $expiration;
+ $this->userManager = $userManager;
}
protected function run($argument) {
diff --git a/apps/files_versions/lib/Command/ExpireVersions.php b/apps/files_versions/lib/Command/ExpireVersions.php
index 09de0ad6d90..7fdaa27afd9 100644
--- a/apps/files_versions/lib/Command/ExpireVersions.php
+++ b/apps/files_versions/lib/Command/ExpireVersions.php
@@ -46,11 +46,11 @@ class ExpireVersions extends Command {
private $userManager;
/**
- * @param IUserManager|null $userManager
- * @param Expiration|null $expiration
+ * @param IUserManager $userManager
+ * @param Expiration $expiration
*/
- public function __construct(IUserManager $userManager = null,
- Expiration $expiration = null) {
+ public function __construct(IUserManager $userManager,
+ Expiration $expiration) {
parent::__construct();
$this->userManager = $userManager;
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index 52afdfdaa5a..217bf02fd39 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -845,7 +845,7 @@ class Storage {
if (is_null(self::$application)) {
self::$application = new Application();
}
- return self::$application->getContainer()->query('Expiration');
+ return self::$application->getContainer()->query(Expiration::class);
}
}