summaryrefslogtreecommitdiffstats
path: root/controller
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-04-20 12:14:42 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-04-20 12:14:42 +0200
commitb9f3136f3a7564b983aef6564f9c7488d5b2b25b (patch)
treea50cc5851cf399df4ba594eacac53f3533c6a2ea /controller
parente56498784f6691d5ceba84ed070f5b6f0d27aafa (diff)
get rid of unneeded settings core class and inject it from the core container
Diffstat (limited to 'controller')
-rw-r--r--controller/apicontroller.php7
-rw-r--r--controller/feedcontroller.php12
-rw-r--r--controller/itemcontroller.php18
-rw-r--r--controller/pagecontroller.php21
4 files changed, 35 insertions, 23 deletions
diff --git a/controller/apicontroller.php b/controller/apicontroller.php
index 7af08d56a..44c888972 100644
--- a/controller/apicontroller.php
+++ b/controller/apicontroller.php
@@ -14,13 +14,13 @@
namespace OCA\News\Controller;
use \OCP\IRequest;
+use \OCP\IConfig;
use \OCP\AppFramework\Controller;
use \OCP\AppFramework\Http;
use \OCP\AppFramework\Http\JSONResponse;
use \OCP\AppFramework\Http\Response;
use \OCA\News\Utility\Updater;
-use \OCA\News\Core\Settings;
class ApiController extends Controller {
@@ -28,7 +28,7 @@ class ApiController extends Controller {
private $settings;
public function __construct($appName, IRequest $request, Updater $updater,
- Settings $settings){
+ IConfig $settings){
parent::__construct($appName, $request);
$this->updater = $updater;
$this->settings = $settings;
@@ -41,7 +41,8 @@ class ApiController extends Controller {
* @API
*/
public function version() {
- $version = $this->settings->getAppValue('installed_version');
+ $version = $this->settings->getAppValue($this->appName,
+ 'installed_version');
$response = new JSONResponse(array('version' => $version));
return $response;
}
diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php
index e9be7e811..afc3de742 100644
--- a/controller/feedcontroller.php
+++ b/controller/feedcontroller.php
@@ -14,11 +14,11 @@
namespace OCA\News\Controller;
use \OCP\IRequest;
+use \OCP\IConfig;
use \OCP\AppFramework\Controller;
use \OCP\AppFramework\Http;
use \OCP\AppFramework\Http\JSONResponse;
-use \OCA\News\Core\Settings;
use \OCA\News\BusinessLayer\ItemBusinessLayer;
use \OCA\News\BusinessLayer\FeedBusinessLayer;
use \OCA\News\BusinessLayer\FolderBusinessLayer;
@@ -40,8 +40,8 @@ class FeedController extends Controller {
FolderBusinessLayer $folderBusinessLayer,
FeedBusinessLayer $feedBusinessLayer,
ItemBusinessLayer $itemBusinessLayer,
- $userId,
- Settings $settings){
+ IConfig $settings,
+ $userId){
parent::__construct($appName, $request);
$this->feedBusinessLayer = $feedBusinessLayer;
$this->folderBusinessLayer = $folderBusinessLayer;
@@ -77,8 +77,10 @@ class FeedController extends Controller {
* @NoAdminRequired
*/
public function active(){
- $feedId = (int) $this->settings->getUserValue('lastViewedFeedId');
- $feedType = $this->settings->getUserValue('lastViewedFeedType');
+ $feedId = (int) $this->settings->getUserValue($this->userId,
+ $this->appName,'lastViewedFeedId');
+ $feedType = $this->settings->getUserValue($this->userId, $this->appName,
+ 'lastViewedFeedType');
// cast from null to int is 0
if($feedType !== null){
diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php
index ec316aabb..99f308be7 100644
--- a/controller/itemcontroller.php
+++ b/controller/itemcontroller.php
@@ -14,11 +14,11 @@
namespace OCA\News\Controller;
use \OCP\IRequest;
+use \OCP\IConfig;
use \OCP\AppFramework\Controller;
use \OCP\AppFramework\Http;
use \OCP\AppFramework\Http\JSONResponse;
-use \OCA\News\Core\Settings;
use \OCA\News\BusinessLayer\BusinessLayerException;
use \OCA\News\BusinessLayer\ItemBusinessLayer;
use \OCA\News\BusinessLayer\FeedBusinessLayer;
@@ -35,8 +35,8 @@ class ItemController extends Controller {
IRequest $request,
FeedBusinessLayer $feedBusinessLayer,
ItemBusinessLayer $itemBusinessLayer,
- $userId,
- Settings $settings){
+ IConfig $settings,
+ $userId){
parent::__construct($appName, $request);
$this->itemBusinessLayer = $itemBusinessLayer;
$this->feedBusinessLayer = $feedBusinessLayer;
@@ -49,15 +49,18 @@ class ItemController extends Controller {
* @NoAdminRequired
*/
public function index(){
- $showAll = $this->settings->getUserValue('showAll') === '1';
+ $showAll = $this->settings->getUserValue($this->userId, $this->appName,
+ 'showAll') === '1';
$limit = $this->params('limit');
$type = (int) $this->params('type');
$id = (int) $this->params('id');
$offset = (int) $this->params('offset', 0);
- $this->settings->setUserValue('lastViewedFeedId', $id);
- $this->settings->setUserValue('lastViewedFeedType', $type);
+ $this->settings->setUserValue($this->userId, $this->appName,
+ 'lastViewedFeedId', $id);
+ $this->settings->setUserValue($this->userId, $this->appName,
+ 'lastViewedFeedType', $type);
$params = array();
@@ -87,7 +90,8 @@ class ItemController extends Controller {
* @NoAdminRequired
*/
public function newItems() {
- $showAll = $this->settings->getUserValue('showAll') === '1';
+ $showAll = $this->settings->getUserValue($this->userId, $this->appName,
+ 'showAll') === '1';
$type = (int) $this->params('type');
$id = (int) $this->params('id');
diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php
index 5b7cf7ea1..fe6fe967a 100644
--- a/controller/pagecontroller.php
+++ b/controller/pagecontroller.php
@@ -14,21 +14,22 @@
namespace OCA\News\Controller;
use \OCP\IRequest;
+use \OCP\IConfig;
use \OCP\AppFramework\Http\JSONResponse;
use \OCP\AppFramework\Controller;
-use \OCA\News\Core\Settings;
-
class PageController extends Controller {
private $settings;
private $l10n;
+ private $userId;
- public function __construct($appName, IRequest $request, Settings $settings,
- $l10n){
+ public function __construct($appName, IRequest $request, IConfig $settings,
+ $l10n, $userId){
parent::__construct($appName, $request);
$this->settings = $settings;
$this->l10n = $l10n;
+ $this->userId = $userId;
}
@@ -45,8 +46,10 @@ class PageController extends Controller {
* @NoAdminRequired
*/
public function settings() {
- $showAll = $this->settings->getUserValue('showAll');
- $compact = $this->settings->getUserValue('compact');
+ $showAll = $this->settings->getUserValue($this->userId, $this->appName,
+ 'showAll');
+ $compact = $this->settings->getUserValue($this->userId, $this->appName,
+ 'compact');
$language = $this->l10n->findLanguage();
$settings = array(
@@ -67,11 +70,13 @@ class PageController extends Controller {
$isCompact = $this->params('compact', null);
if($isShowAll !== null) {
- $this->settings->setUserValue('showAll', $isShowAll);
+ $this->settings->setUserValue($this->userId, $this->appName,
+ 'showAll', $isShowAll);
}
if($isCompact !== null) {
- $this->settings->setUserValue('compact', $isCompact);
+ $this->settings->setUserValue($this->userId, $this->appName,
+ 'compact', $isCompact);
}
return new JSONResponse();