From 066b4b5a22a89fe3b38d37f09153090091928cd5 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 13 May 2014 21:57:44 +0200 Subject: move to new controller layout --- controller/itemapicontroller.php | 44 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'controller/itemapicontroller.php') 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; } -- cgit v1.2.3