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:
parent
8d17d7f6cd
commit
cd53498256
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue