summaryrefslogtreecommitdiffstats
path: root/controller/itemapicontroller.php
diff options
context:
space:
mode:
Diffstat (limited to 'controller/itemapicontroller.php')
-rw-r--r--controller/itemapicontroller.php44
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;
}