diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-06 15:26:45 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-06 15:26:58 +0200 |
commit | dbd18a20993221baf9e851fbd8eba1a48c411b3d (patch) | |
tree | d6bb96ddde1d70e960e1e8fc7b3d2d8a1ce3ca79 /controller/itemcontroller.php | |
parent | 3c4044970e38820d67560e219dd94dc9e96b0387 (diff) |
get rid of deprecated getParams and renderJSON method to ease transition to built in appframework
Diffstat (limited to 'controller/itemcontroller.php')
-rw-r--r-- | controller/itemcontroller.php | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index a3f632e39..637c5fd49 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -28,6 +28,8 @@ namespace OCA\News\Controller; use \OCA\AppFramework\Controller\Controller; use \OCA\AppFramework\Core\API; use \OCA\AppFramework\Http\Request; +use \OCA\AppFramework\Http\JSONResponse; +use \OCA\AppFramework\Http\Http; use \OCA\News\BusinessLayer\BusinessLayerException; use \OCA\News\BusinessLayer\ItemBusinessLayer; @@ -85,7 +87,7 @@ class ItemController extends Controller { // in that case just return an empty array } catch(BusinessLayerException $ex) {} - return $this->renderJSON($params); + return new JSONResponse($params); } @@ -114,7 +116,7 @@ class ItemController extends Controller { // in that case just return an empty array } catch(BusinessLayerException $ex) {} - return $this->renderJSON($params); + return new JSONResponse($params); } @@ -135,9 +137,11 @@ class ItemController extends Controller { public function star(){ try { $this->setStarred(true); - return $this->renderJSON(); + return new JSONResponse(); } catch(BusinessLayerException $ex) { - return $this->renderJSON(array(), $ex->getMessage()); + return new JSONResponse(array( + 'msg' => $ex->getMessage() + ), Http::STATUS_NOT_FOUND); } } @@ -150,9 +154,11 @@ class ItemController extends Controller { public function unstar(){ try { $this->setStarred(false); - return $this->renderJSON(); + return new JSONResponse(); } catch(BusinessLayerException $ex) { - return $this->renderJSON(array(), $ex->getMessage()); + return new JSONResponse(array( + 'msg' => $ex->getMessage() + ), Http::STATUS_NOT_FOUND); } } @@ -173,9 +179,11 @@ class ItemController extends Controller { public function read(){ try { $this->setRead(true); - return $this->renderJSON(); + return new JSONResponse(); } catch(BusinessLayerException $ex) { - return $this->renderJSON(array(), $ex->getMessage()); + return new JSONResponse(array( + 'msg' => $ex->getMessage() + ), Http::STATUS_NOT_FOUND); } } @@ -188,9 +196,11 @@ class ItemController extends Controller { public function unread(){ try { $this->setRead(false); - return $this->renderJSON(); + return new JSONResponse(); } catch(BusinessLayerException $ex) { - return $this->renderJSON(array(), $ex->getMessage()); + return new JSONResponse(array( + 'msg' => $ex->getMessage() + ), Http::STATUS_NOT_FOUND); } } @@ -209,7 +219,7 @@ class ItemController extends Controller { $params = array( 'feeds' => $this->feedBusinessLayer->findAll($userId) ); - return $this->renderJSON($params); + return new JSONResponse($params); } |