diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-13 21:57:44 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-13 21:57:44 +0200 |
commit | 066b4b5a22a89fe3b38d37f09153090091928cd5 (patch) | |
tree | e01b7eaf641314259de1a54f146fa3e5d582ce02 | |
parent | fb85040af65e77e6f4b2e596e259b38b510a8b60 (diff) |
move to new controller layout
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | appinfo/app.json | 4 | ||||
-rw-r--r-- | appinfo/info.xml | 2 | ||||
-rw-r--r-- | controller/entityapiserializer.php | 44 | ||||
-rw-r--r-- | controller/feedapicontroller.php | 62 | ||||
-rw-r--r-- | controller/feedcontroller.php | 103 | ||||
-rw-r--r-- | controller/folderapicontroller.php | 69 | ||||
-rw-r--r-- | controller/foldercontroller.php | 57 | ||||
-rw-r--r-- | controller/itemapicontroller.php | 44 | ||||
-rw-r--r-- | controller/itemcontroller.php | 86 | ||||
-rw-r--r-- | controller/pagecontroller.php | 8 | ||||
-rw-r--r-- | controller/utilityapicontroller.php | 1 |
12 files changed, 217 insertions, 264 deletions
diff --git a/.travis.yml b/.travis.yml index 60eacefd5..04950830e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: php php: - - 5.3 - 5.4 - 5.5 diff --git a/appinfo/app.json b/appinfo/app.json index 2cd5cafe3..33e54d8a2 100644 --- a/appinfo/app.json +++ b/appinfo/app.json @@ -35,8 +35,8 @@ "databases": ["pgsql", "sqlite3", "mysql"], "categories": ["Multimedia"], "dependencies": { - "php": ">=5.3.6", - "owncloud": ">=6.0.3", + "php": ">=5.4", + "owncloud": ">=7", "libs": { "curl": "*" } diff --git a/appinfo/info.xml b/appinfo/info.xml index f6f84644e..7a0ea048e 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -6,5 +6,5 @@ <licence>AGPL</licence> <author>Alessandro Cosentino, Bernhard Posselt, Jan-Christoph Borchardt. Powered by SimplePie (Ryan Parman, Geoffrey Sneddon, Ryan McCue and contributors).</author> <version>2.002</version> - <require>6.0.3</require> + <require>7</require> </info> diff --git a/controller/entityapiserializer.php b/controller/entityapiserializer.php new file mode 100644 index 000000000..ef5e20fbe --- /dev/null +++ b/controller/entityapiserializer.php @@ -0,0 +1,44 @@ +<?php +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Alessandro Cosentino <cosenal@gmail.com> + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Alessandro Cosentino 2012 + * @copyright Bernhard Posselt 2012, 2014 + */ + +namespace OCA\News\Controller; + +use \OCP\AppFramework\Http\IResponseSerializer; + +class EntityApiSeralizer implements IResponseSerializer { + + + public function __construct($level) { + $this->level = $level; + } + + + /** + * Wrap a list of entities in an array with $level as index and serialize + * them using the toAPI method + */ + public function serialize($data) { + if(!is_array($data)) { + $data = array($data); + } + + $response = array( + $this->level => array(); + ); + + foreach($data as $entity) { + $response[$this->level][] = $entity->toAPI() + } + } + +}
\ No newline at end of file diff --git a/controller/feedapicontroller.php b/controller/feedapicontroller.php index 883732c87..b326a1825 100644 --- a/controller/feedapicontroller.php +++ b/controller/feedapicontroller.php @@ -28,6 +28,8 @@ use \OCA\News\BusinessLayer\BusinessLayerConflictException; class FeedApiController extends ApiController { + use JSONHttpError; + private $itemBusinessLayer; private $feedBusinessLayer; private $folderBusinessLayer; @@ -66,6 +68,7 @@ class FeedApiController extends ApiController { ); $feeds = $this->feedBusinessLayer->findAll($this->userId); + foreach ($feeds as $feed) { array_push($result['feeds'], $feed->toAPI()); } @@ -112,19 +115,9 @@ class FeedApiController extends ApiController { return $result; } catch(BusinessLayerConflictException $ex) { - - return new JSONResponse( - array('message' => $ex->getMessage()), - Http::STATUS_CONFLICT - ); - + return $this->error($ex, Http::STATUS_CONFLICT); } catch(BusinessLayerException $ex) { - - return new JSONResponse( - array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND - ); - + return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -140,10 +133,7 @@ class FeedApiController extends ApiController { try { $this->feedBusinessLayer->delete($feedId, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse( - array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND - ); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -152,11 +142,11 @@ class FeedApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS + * + * @param int $feedId + * @param int $newestItemId */ - public function read() { - $feedId = (int) $this->params('feedId'); - $newestItemId = (int) $this->params('newestItemId'); - + public function read($feedId, $newestItemId) { $this->itemBusinessLayer->readFeed($feedId, $newestItemId, $this->userId); } @@ -165,16 +155,15 @@ class FeedApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS + * + * @param int $feedId + * @param int $folderId */ - public function move() { - $feedId = (int) $this->params('feedId'); - $folderId = (int) $this->params('folderId'); - + public function move($feedId, $folderId) { try { $this->feedBusinessLayer->move($feedId, $folderId, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -183,16 +172,15 @@ class FeedApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS + * + * @param int $feedId + * @param string $feedTitle */ - public function rename() { - $feedId = (int) $this->params('feedId'); - $feedTitle = $this->params('feedTitle'); - + public function rename($feedId, $feedTitle) { try { $this->feedBusinessLayer->rename($feedId, $feedTitle, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -212,17 +200,17 @@ class FeedApiController extends ApiController { )); } - return new JSONResponse($result); + return $result; } /** * @NoCSRFRequired + * + * @param string $userId + * @param int $feedId */ - public function update() { - $userId = $this->params('userId'); - $feedId = (int) $this->params('feedId'); - + public function update($userId, $feedId) { try { $this->feedBusinessLayer->update($feedId, $userId); // ignore update failure (feed could not be reachable etc, we dont care) diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php index 02e523dff..5489f555c 100644 --- a/controller/feedcontroller.php +++ b/controller/feedcontroller.php @@ -17,7 +17,6 @@ use \OCP\IRequest; use \OCP\IConfig; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http; -use \OCP\AppFramework\Http\JSONResponse; use \OCA\News\BusinessLayer\ItemBusinessLayer; use \OCA\News\BusinessLayer\FeedBusinessLayer; @@ -29,6 +28,8 @@ use \OCA\News\Db\FeedType; class FeedController extends Controller { + use JSONHttpError; + private $feedBusinessLayer; private $folderBusinessLayer; private $itemBusinessLayer; @@ -72,7 +73,7 @@ class FeedController extends Controller { // simply ignore it and do not add the newestItemId } catch (BusinessLayerException $ex) {} - return new JSONResponse($params); + return $params; } @@ -108,24 +109,22 @@ class FeedController extends Controller { $feedType = FeedType::SUBSCRIPTIONS; } - $params = array( + return array( 'activeFeed' => array( 'id' => $feedId, 'type' => $feedType ) ); - - return new JSONResponse($params); } /** * @NoAdminRequired + * + * @param string $url + * @param int $parentFolderId */ - public function create(){ - $url = $this->params('url'); - $parentFolderId = (int) $this->params('parentFolderId'); - + public function create($url, $parentFolderId){ try { // we need to purge deleted feeds if a feed is created to // prevent already exists exceptions @@ -144,47 +143,40 @@ class FeedController extends Controller { // simply ignore it and do not add the newestItemId } catch (BusinessLayerException $ex) {} - return new JSONResponse($params); + return $params; } catch(BusinessLayerConflictException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_CONFLICT); - + return $this->error($ex, Http::STATUS_CONFLICT); } catch(BusinessLayerException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_UNPROCESSABLE_ENTITY); + return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } } /** * @NoAdminRequired + * + * @param int $feedId */ - public function delete(){ - $feedId = (int) $this->params('feedId'); - + public function delete($feedId){ try { $this->feedBusinessLayer->markDeleted($feedId, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } /** * @NoAdminRequired + * + * @param int $feedId */ - public function update(){ + public function update($feedId){ try { - $feedId = (int) $this->params('feedId'); - $feed = $this->feedBusinessLayer->update($feedId, $this->userId); - $params = array( + return array( 'feeds' => array( // only pass unreadcount to not accidentally readd // the feed again @@ -195,75 +187,69 @@ class FeedController extends Controller { ) ); - return new JSONResponse($params); - } catch(BusinessLayerException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } /** * @NoAdminRequired + * + * @param int $feedId + * @param int $parentFolderId */ - public function move(){ - $feedId = (int) $this->params('feedId'); - $parentFolderId = (int) $this->params('parentFolderId'); - + public function move($feedId, $parentFolderId){ try { $this->feedBusinessLayer->move($feedId, $parentFolderId, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } /** * @NoAdminRequired + * + * @param int $feedId + * @param string $feedTitle */ public function rename() { - $feedId = (int) $this->params('feedId'); - $feedTitle = $this->params('feedTitle'); - try { $this->feedBusinessLayer->rename($feedId, $feedTitle, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } + /** * @NoAdminRequired + * + * @param array $json */ - public function import() { - $json = $this->params('json'); - + public function import($json) { $feed = $this->feedBusinessLayer->importArticles($json, $this->userId); $params = array(); + if($feed) { $params['feeds'] = array($feed); } - return new JSONResponse($params); + return $params; } /** * @NoAdminRequired + * + * @param int $feedId + * @param int $highestItemId */ - public function read(){ - $feedId = (int) $this->params('feedId'); - $highestItemId = (int) $this->params('highestItemId'); - + public function read($feedId, $highestItemId){ $this->itemBusinessLayer->readFeed($feedId, $highestItemId, $this->userId); - $params = array( + return array( 'feeds' => array( array( 'id' => $feedId, @@ -271,22 +257,19 @@ class FeedController extends Controller { ) ) ); - return new JSONResponse($params); } /** * @NoAdminRequired + * + * @param int $feedId */ public function restore(){ - $feedId = (int) $this->params('feedId'); - try { $this->feedBusinessLayer->unmarkDeleted($feedId, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } diff --git a/controller/folderapicontroller.php b/controller/folderapicontroller.php index 40ffc1389..4e9f3e00c 100644 --- a/controller/folderapicontroller.php +++ b/controller/folderapicontroller.php @@ -27,6 +27,8 @@ use \OCA\News\BusinessLayer\BusinessLayerValidationException; class FolderApiController extends ApiController { + use JSONHttpError; + private $folderBusinessLayer; private $itemBusinessLayer; private $userId; @@ -49,15 +51,9 @@ class FolderApiController extends ApiController { * @CORS */ public function index() { - $result = array( - 'folders' => array() - ); - - foreach ($this->folderBusinessLayer->findAll($this->userId) as $folder) { - array_push($result['folders'], $folder->toAPI()); - } + $this->registerSerializer(new EntityApiSerializer('folders')); - return new JSONResponse($result); + return $this->folderBusinessLayer->findAll($this->userId); } @@ -65,27 +61,21 @@ class FolderApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS + * + * @param string $name */ - public function create() { - $folderName = $this->params('name'); - $result = array( - 'folders' => array() - ); - + public function create($name) { try { $this->folderBusinessLayer->purgeDeleted($this->userId, false); $folder = $this->folderBusinessLayer->create($folderName, $this->userId); - array_push($result['folders'], $folder->toAPI()); + + $this->registerSerializer(new EntityApiSerializer('folders')); + return $folder; - return new JSONResponse($result); - } catch(BusinessLayerValidationException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_UNPROCESSABLE_ENTITY); - + return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } catch(BusinessLayerConflictException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_CONFLICT); + return $this->error($ex, Http::STATUS_CONFLICT); } } @@ -94,15 +84,14 @@ class FolderApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS + * + * @param int $folderId */ - public function delete() { - $folderId = (int) $this->params('folderId'); - + public function delete($folderId) { try { $this->folderBusinessLayer->delete($folderId, $this->userId); } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -111,25 +100,19 @@ class FolderApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS + * @param int $folderId + * @param string $name */ - public function update() { - $folderId = (int) $this->params('folderId'); - $folderName = $this->params('name'); - + public function update($folderId, $name) { try { $this->folderBusinessLayer->rename($folderId, $folderName, $this->userId); } catch(BusinessLayerValidationException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_UNPROCESSABLE_ENTITY); - + return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } catch(BusinessLayerConflictException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_CONFLICT); - + return $this->error($ex, Http::STATUS_CONFLICT); } catch(BusinessLayerException $ex) { - return new JSONResponse(array('message' => $ex->getMessage()), - Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -138,11 +121,11 @@ class FolderApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS + * + * @param int $folderId + * @param int $newestItemId */ - public function read() { - $folderId = (int) $this->params('folderId'); - $newestItemId = (int) $this->params('newestItemId'); - + public function read($folderId, $newestItemId) { $this->itemBusinessLayer->readFolder($folderId, $newestItemId, $this->userId); } diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php index 76476dd7a..9b0db2be7 100644 --- a/controller/foldercontroller.php +++ b/controller/foldercontroller.php @@ -16,7 +16,6 @@ namespace OCA\News\Controller; use \OCP\IRequest; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http; -use \OCP\AppFramework\Http\JSONResponse; use \OCA\News\BusinessLayer\FolderBusinessLayer; use \OCA\News\BusinessLayer\FeedBusinessLayer; @@ -25,6 +24,7 @@ use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\BusinessLayerConflictException; use \OCA\News\BusinessLayer\BusinessLayerValidationException; + class FolderController extends Controller { use JSONHttpError; @@ -53,10 +53,9 @@ class FolderController extends Controller { */ public function index(){ $folders = $this->folderBusinessLayer->findAll($this->userId); - $result = array( + return array( 'folders' => $folders ); - return $result; } @@ -105,10 +104,9 @@ class FolderController extends Controller { $this->folderBusinessLayer->purgeDeleted($this->userId, false); $folder = $this->folderBusinessLayer->create($folderName, $this->userId); - $params = array( + return array( 'folders' => array($folder) ); - return $params; } catch(BusinessLayerConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); @@ -135,67 +133,54 @@ class FolderController extends Controller { /** * @NoAdminRequired + * + * @param string $folderName + * @param int $folderId */ - public function rename(){ - $folderName = $this->params('folderName'); - $folderId = (int) $this->params('folderId'); - + public function rename($folderName, $folderId){ try { $folder = $this->folderBusinessLayer->rename($folderId, $folderName, $this->userId); - $params = array( + return array( 'folders' => array($folder) ); - return new JSONResponse($params); - + } catch(BusinessLayerConflictException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_CONFLICT); - + return $this->error($ex, Http::STATUS_CONFLICT); } catch(BusinessLayerValidationException $ex) { - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_UNPROCESSABLE_ENTITY); - + return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } catch (BusinessLayerException $ex){ - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } } /** * @NoAdminRequired + * + * @param int $folderId + * @param int $highestItemId */ - public function read(){ - $folderId = (int) $this->params('folderId'); - $highestItemId = (int) $this->params('highestItemId'); - + public function read($folderId, $highestItemId){ $this->itemBusinessLayer->readFolder($folderId, $highestItemId, $this->userId); - $params = array( + return array( 'feeds' => $this->feedBusinessLayer->findAll($this->userId) ); - return new JSONResponse($params); } /** * @NoAdminRequired + * + * @param int $folderId */ - public function restore(){ - $folderId = (int) $this->params('folderId'); - + public function restore($folderId){ try { $this->folderBusinessLayer->unmarkDeleted($folderId, $this->userId); } catch (BusinessLayerException $ex){ - return new JSONResponse(array( - 'msg' => $ex->getMessage() - ), Http::STATUS_NOT_FOUND); + return $this->error($ex, Http::STATUS_NOT_FOUND); } - } diff --git a/controller/itemapicontroller.php b/controller/itemapicontroller.php index 767023877..8cd8b5578 100644 --- a/controller/itemapicontroller.php +++ b/controller/itemapicontroller.php @@ -16,7 +16,6 @@ namespace OCA\News\Controller; use \OCP\IRequest; use \OCP\AppFramework\ApiController; use \OCP\AppFramework\Http; -use \OCP\AppFramework\Http\JSONResponse; use \OCA\News\BusinessLayer\ItemBusinessLayer; use \OCA\News\BusinessLayer\BusinessLayerException; @@ -50,24 +49,10 @@ class ItemApiController extends ApiController { * @param int $offset */ public function index($type, $id, $getRead, $batchSize=20, $offset=0) { - $result = array( - 'items' => array() - ); - - $items = $this->itemBusinessLayer->findAll( - $id, - $type, - $batchSize, - $offset, - $showAll, - $this->userId - ); - - foreach ($items as $item) { - array_push($result['items'], $item->toAPI()); - } + $this->registerSerializer(new EntityApiSerializer('items')); - return $result; + return $this->itemBusinessLayer->findAll($id, $type, $batchSize, $offset, + $showAll, $this->userId); } @@ -81,23 +66,10 @@ class ItemApiController extends ApiController { * @param int $lastModified */ public function updated($type, $id, $lastModified=0) { - $result = array( - 'items' => array() - ); - - $items = $this->itemBusinessLayer->findAllNew( - $id, - $type, - $lastModified, - true, - $this->userId - ); - - foreach ($items as $item) { - array_push($result['items'], $item->toAPI()); - } + $this->registerSerializer(new EntityApiSerializer('items')); - $result; + return $this->itemBusinessLayer->findAllNew($id, $type, $lastModified, + true, $this->userId); } @@ -219,8 +191,8 @@ class ItemApiController extends ApiController { private function setMultipleStarred($isStarred, $items) { foreach($items as $item) { try { - $this->itemBusinessLayer->star($item['feedId'], - $item['guidHash'], $isStarred, $this->userId); + $this->itemBusinessLayer->star($item['feedId'], $item['guidHash'], + $isStarred, $this->userId); } catch(BusinessLayerException $ex) { continue; } diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index b7836fdaa..3313f583b 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -17,7 +17,6 @@ use \OCP\IRequest; use \OCP\IConfig; use \OCP\AppFramework\Controller; use \OCP\AppFramework\Http; -use \OCP\AppFramework\Http\JSONResponse; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\ItemBusinessLayer; @@ -26,6 +25,8 @@ use \OCA\News\BusinessLayer\FeedBusinessLayer; class ItemController extends Controller { + use JSONHttpError; + private $itemBusinessLayer; private $feedBusinessLayer; private $userId; @@ -47,16 +48,16 @@ class ItemController extends Controller { /** * @NoAdminRequired + * + * @param int $type + * @param int $id + * @param int $limit + * @param int $offset */ - public function index(){ + public function index($type, $id, $limit, $offset=0) { $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($this->userId, $this->appName, 'lastViewedFeedId', $id); $this->settings->setUserValue($this->userId, $this->appName, @@ -78,6 +79,7 @@ class ItemController extends Controller { $params['items'] = $this->itemBusinessLayer->findAll($id, $type, $limit, $offset, $showAll, $this->userId); + // this gets thrown if there are no items // in that case just return an empty array } catch(BusinessLayerException $ex) {} @@ -88,15 +90,15 @@ class ItemController extends Controller { /** * @NoAdminRequired + * + * @param int $type + * @param int $id + * @param int $lastModified */ - public function newItems() { + public function newItems($type, $id, $lastModified=0) { $showAll = $this->settings->getUserValue($this->userId, $this->appName, 'showAll') === '1'; - $type = (int) $this->params('type'); - $id = (int) $this->params('id'); - $lastModified = (int) $this->params('lastModified', 0); - $params = array(); try { @@ -105,97 +107,93 @@ class ItemController extends Controller { $params['starred'] = $this->itemBusinessLayer->starredCount($this->userId); $params['items'] = $this->itemBusinessLayer->findAllNew($id, $type, $lastModified, $showAll, $this->userId); + // this gets thrown if there are no items // in that case just return an empty array } catch(BusinessLayerException $ex) {} - return new $params; + return $params; } - private function setStarred($isStarred){ - $feedId = (int) $this->params('feedId'); - $guidHash = $this->params('guidHash'); - + private function setStarred($isStarred, $feedId, $guidHash){ |