Use more magic DI in files_versions

There is no need to register this. The system can figure out by itself
what it needs to do :)

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-05-11 22:25:07 +02:00
parent 8d17d7f6cd
commit cd53498256
No known key found for this signature in database
GPG Key ID: F941078878347C0C
4 changed files with 8 additions and 28 deletions

View File

@ -40,16 +40,6 @@ class Application extends App {
*/ */
$container->registerCapability(Capabilities::class); $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 * Register $principalBackend for the DAV collection
*/ */

View File

@ -44,23 +44,13 @@ class ExpireVersions extends \OC\BackgroundJob\TimedJob {
*/ */
private $userManager; private $userManager;
public function __construct(IUserManager $userManager = null, Expiration $expiration = null) { public function __construct(IUserManager $userManager, Expiration $expiration) {
// Run once per 30 minutes // Run once per 30 minutes
$this->setInterval(60 * 30); $this->setInterval(60 * 30);
if (is_null($expiration) || is_null($userManager)) {
$this->fixDIForJobs();
} else {
$this->expiration = $expiration; $this->expiration = $expiration;
$this->userManager = $userManager; $this->userManager = $userManager;
} }
}
protected function fixDIForJobs() {
$application = new Application();
$this->expiration = $application->getContainer()->query('Expiration');
$this->userManager = \OC::$server->getUserManager();
}
protected function run($argument) { protected function run($argument) {
$maxAge = $this->expiration->getMaxAgeAsTimestamp(); $maxAge = $this->expiration->getMaxAgeAsTimestamp();

View File

@ -46,11 +46,11 @@ class ExpireVersions extends Command {
private $userManager; private $userManager;
/** /**
* @param IUserManager|null $userManager * @param IUserManager $userManager
* @param Expiration|null $expiration * @param Expiration $expiration
*/ */
public function __construct(IUserManager $userManager = null, public function __construct(IUserManager $userManager,
Expiration $expiration = null) { Expiration $expiration) {
parent::__construct(); parent::__construct();
$this->userManager = $userManager; $this->userManager = $userManager;

View File

@ -845,7 +845,7 @@ class Storage {
if (is_null(self::$application)) { if (is_null(self::$application)) {
self::$application = new Application(); self::$application = new Application();
} }
return self::$application->getContainer()->query('Expiration'); return self::$application->getContainer()->query(Expiration::class);
} }
} }