From 547b977c492257bcd4530ab9c2f2bbb22051128e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 25 Nov 2016 09:57:35 +0100 Subject: use non depricated public api to register background job (#59) --- lib/AppInfo/Application.php | 4 +++- lib/Config/AppConfig.php | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index ce366ecaa..be81c0f2b 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -16,6 +16,7 @@ namespace OCA\News\AppInfo; use HTMLPurifier; use HTMLPurifier_Config; +use OCP\BackgroundJob\IJobList; use PicoFeed\Config\Config as PicoFeedConfig; use PicoFeed\Reader\Reader as PicoFeedReader; @@ -63,7 +64,8 @@ class Application extends App { $this->registerService(AppConfig::class, function($c) { $config = new AppConfig( $c->query(INavigationManager::class), - $c->query(IURLGenerator::class) + $c->query(IURLGenerator::class), + $c->query(IJobList::class) ); $config->loadConfig($c->query('info')); diff --git a/lib/Config/AppConfig.php b/lib/Config/AppConfig.php index bb79a0ce3..9c30b4f80 100644 --- a/lib/Config/AppConfig.php +++ b/lib/Config/AppConfig.php @@ -13,6 +13,7 @@ namespace OCA\News\Config; +use OCP\BackgroundJob\IJobList; use SimpleXMLElement; use OCP\INavigationManager; @@ -26,6 +27,7 @@ class AppConfig { private $config; private $navigationManager; private $urlGenerator; + private $jobList; /** * TODO: External deps that are needed: @@ -33,10 +35,12 @@ class AppConfig { * - connect to hooks */ public function __construct(INavigationManager $navigationManager, - IURLGenerator $urlGenerator) { + IURLGenerator $urlGenerator, + IJobList $jobList) { $this->navigationManager = $navigationManager; $this->urlGenerator = $urlGenerator; $this->config = []; + $this->jobList = $jobList; } @@ -83,9 +87,7 @@ class AppConfig { public function registerAll() { $this->registerNavigation(); $this->registerHooks(); - // IJob API is fucked up, so silence the code checker - $class = '\OCP\BackgroundJob'; - $class::addRegularTask($this->config['cron']['job'], 'run'); + $this->jobList->add('OC\BackgroundJob\Legacy\RegularJob', [$this->config['cron']['job'], 'run']); App::registerAdmin($this->config['id'], $this->config['admin']); } -- cgit v1.2.3