summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-11-25 09:57:35 +0100
committerBernhard Posselt <BernhardPosselt@users.noreply.github.com>2016-11-25 09:57:35 +0100
commit547b977c492257bcd4530ab9c2f2bbb22051128e (patch)
treebcb663809074864e50488e8331695789a9d91e6e
parent72e4949ea88812ee99bdb771ef35b4cbcabb26df (diff)
use non depricated public api to register background job (#59)
-rw-r--r--lib/AppInfo/Application.php4
-rw-r--r--lib/Config/AppConfig.php10
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']);
}