summaryrefslogtreecommitdiffstats
path: root/dependencyinjection
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-09-02 02:43:25 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-09-02 02:43:32 +0200
commit38297af11f458b30af3cbdc42cf3407d6aff44ab (patch)
tree6c61f09234182c78fe291bcd439284c8e77e7ffe /dependencyinjection
parent1b144268cbb49854aaba1c04c773dcf2f9cf0b7a (diff)
move configuration values into a config file, fix #167
Diffstat (limited to 'dependencyinjection')
-rw-r--r--dependencyinjection/dicontainer.php35
1 files changed, 26 insertions, 9 deletions
diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php
index de49236c6..697ee0b88 100644
--- a/dependencyinjection/dicontainer.php
+++ b/dependencyinjection/dicontainer.php
@@ -25,6 +25,8 @@
namespace OCA\News\DependencyInjection;
+use \OC\Files\View;
+
use \OCA\AppFramework\DependencyInjection\DIContainer as BaseContainer;
use \OCA\AppFramework\Middleware\MiddlewareDispatcher;
@@ -49,6 +51,7 @@ use \OCA\News\External\FolderAPI;
use \OCA\News\External\FeedAPI;
use \OCA\News\External\ItemAPI;
+use \OCA\News\Utility\Config;
use \OCA\News\Utility\Fetcher;
use \OCA\News\Utility\FeedFetcher;
use \OCA\News\Utility\TwitterFetcher;
@@ -77,14 +80,29 @@ class DIContainer extends BaseContainer {
/**
* Configuration values
*/
- $this['autoPurgeMinimumInterval'] = 60; // seconds, used to define how
- // long deleted folders and feeds
- // should still be kept for an
- // undo actions
- $this['autoPurgeCount'] = 200; // number of allowed unread articles per feed
- $this['simplePieCacheDuration'] = 30*60; // seconds
- $this['feedFetcherTimeout'] = 60; // seconds
- $this['useCronUpdates'] = true;
+ $this['configView'] = $this->share(function($c) {
+ $view = new View('/news/config');
+ if (!$view->file_exists('')) {
+ $view->mkdir('');
+ }
+
+ return $view;
+ });
+
+ $this['Config'] = $this->share(function($c) {
+ $config = new Config($c['configView'], $c['API']);
+ $config->read('config.json', true);
+ return $config;
+ });
+
+ // set by config class from config file
+ // look up defaults in utility/config.php
+ $this['autoPurgeMinimumInterval'] = $this['Config']->getAutoPurgeMinimumInterval();
+ $this['autoPurgeCount'] = $this['Config']->getAutoPurgeCount();
+ $this['simplePieCacheDuration'] = $this['Config']->getSimplePieCacheDuration();
+ $this['feedFetcherTimeout'] = $this['Config']->getFeedFetcherTimeout();
+ $this['useCronUpdates'] = $this['Config']->getUseCronUpdates();
+
$this['simplePieCacheDirectory'] = $this->share(function($c) {
$directory = $c['API']->getSystemValue('datadirectory') .
@@ -94,7 +112,6 @@ class DIContainer extends BaseContainer {
mkdir($directory, 0770, true);
}
return $directory;
-
});
$this['HTMLPurifier'] = $this->share(function($c) {