diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-19 13:20:54 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-19 13:21:11 +0200 |
commit | 517e4ca5435106ab5304849248cbea4e9dffd4b0 (patch) | |
tree | 0f00076f012791b39c710994f695abf723546062 /controller/exportcontroller.php | |
parent | bd35b98d2c130f058b182f726636ee971625823b (diff) |
split up api class for easier testing and clearer code
Diffstat (limited to 'controller/exportcontroller.php')
-rw-r--r-- | controller/exportcontroller.php | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/controller/exportcontroller.php b/controller/exportcontroller.php index 33cb05204..a0011f9e6 100644 --- a/controller/exportcontroller.php +++ b/controller/exportcontroller.php @@ -32,7 +32,6 @@ use \OCP\AppFramework\Http\JSONResponse; use \OCP\AppFramework\Http\Response; use \OCA\News\Http\TextDownloadResponse; -use \OCA\News\Core\API; use \OCA\News\BusinessLayer\FeedBusinessLayer; use \OCA\News\BusinessLayer\FolderBusinessLayer; use \OCA\News\BusinessLayer\ItemBusinessLayer; @@ -44,19 +43,21 @@ class ExportController extends Controller { private $folderBusinessLayer; private $feedBusinessLayer; private $itemBusinessLayer; - private $api; + private $userId; - public function __construct(API $api, IRequest $request, + public function __construct($appName, + IRequest $request, FeedBusinessLayer $feedBusinessLayer, FolderBusinessLayer $folderBusinessLayer, ItemBusinessLayer $itemBusinessLayer, - OPMLExporter $opmlExporter){ - parent::__construct($api->getAppName(), $request); + OPMLExporter $opmlExporter, + $userId){ + parent::__construct($appName, $request); $this->feedBusinessLayer = $feedBusinessLayer; $this->folderBusinessLayer = $folderBusinessLayer; $this->opmlExporter = $opmlExporter; $this->itemBusinessLayer = $itemBusinessLayer; - $this->api = $api; + $this->userId = $userId; } @@ -65,9 +66,8 @@ class ExportController extends Controller { * @NoCSRFRequired */ public function opml(){ - $userId = $this->api->getUserId(); - $feeds = $this->feedBusinessLayer->findAll($userId); - $folders = $this->folderBusinessLayer->findAll($userId); + $feeds = $this->feedBusinessLayer->findAll($this->userId); + $folders = $this->folderBusinessLayer->findAll($this->userId); $opml = $this->opmlExporter->build($folders, $feeds)->saveXML(); return new TextDownloadResponse($opml, 'subscriptions.opml', 'text/xml'); } @@ -78,9 +78,8 @@ class ExportController extends Controller { * @NoCSRFRequired */ public function articles(){ - $userId = $this->api->getUserId(); - $feeds = $this->feedBusinessLayer->findAll($userId); - $items = $this->itemBusinessLayer->getUnreadOrStarred($userId); + $feeds = $this->feedBusinessLayer->findAll($this->userId); + $items = $this->itemBusinessLayer->getUnreadOrStarred($this->userId); // build assoc array for fast access $feedsDict = array(); |