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 /controller/itemapicontroller.php | |
parent | fb85040af65e77e6f4b2e596e259b38b510a8b60 (diff) |
move to new controller layout
Diffstat (limited to 'controller/itemapicontroller.php')
-rw-r--r-- | controller/itemapicontroller.php | 44 |
1 files changed, 8 insertions, 36 deletions
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; } |