summaryrefslogtreecommitdiffstats
path: root/controller
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-06-25 11:22:08 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-06-25 11:22:08 +0200
commit06367d8b81407fc2948e0f666b38f4de2dffbd89 (patch)
treed5cfb74e70560f3abce5aeccf8994dcbe2829e24 /controller
parent60c4dfbd9661b93bce14a6a429a3f23d19b5327c (diff)
style fixes
Diffstat (limited to 'controller')
-rw-r--r--controller/entityapiserializer.php4
-rw-r--r--controller/feedapicontroller.php73
-rw-r--r--controller/feedcontroller.php108
-rw-r--r--controller/folderapicontroller.php49
-rw-r--r--controller/foldercontroller.php79
-rw-r--r--controller/itemapicontroller.php120
-rw-r--r--controller/itemcontroller.php75
-rw-r--r--controller/jsonhttperror.php2
8 files changed, 289 insertions, 221 deletions
diff --git a/controller/entityapiserializer.php b/controller/entityapiserializer.php
index eb60bc7c5..5153d9aa3 100644
--- a/controller/entityapiserializer.php
+++ b/controller/entityapiserializer.php
@@ -26,11 +26,13 @@ class EntityApiSerializer {
/**
* Call toAPI() method on all entities. Works on
- * @param mixed $data:
+ *
+ * @param mixed $data :
* * Entity
* * Entity[]
* * array('level' => Entity[])
* * Response
+ * @return array|mixed
*/
public function serialize($data) {
diff --git a/controller/feedapicontroller.php b/controller/feedapicontroller.php
index 4ba3b9be5..f0af19f4a 100644
--- a/controller/feedapicontroller.php
+++ b/controller/feedapicontroller.php
@@ -60,7 +60,6 @@ class FeedApiController extends ApiController {
public function index() {
$result = [
- 'feeds' => [],
'starredCount' => $this->itemService->starredCount($this->userId),
'feeds' => $this->feedService->findAll($this->userId)
];
@@ -76,14 +75,15 @@ class FeedApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param string $url
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param string $url
+ * @param int $folderId
+ * @return array|mixed|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($url, $folderId=0) {
try {
$this->feedService->purgeDeleted($this->userId, false);
@@ -107,19 +107,22 @@ class FeedApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function delete($feedId) {
try {
$this->feedService->delete($feedId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
@@ -136,37 +139,43 @@ class FeedApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @param int $folderId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function move($feedId, $folderId) {
try {
$this->feedService->move($feedId, $folderId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- * @param string $feedTitle
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @param string $feedTitle
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function rename($feedId, $feedTitle) {
try {
$this->feedService->rename($feedId, $feedTitle, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php
index 3b9ab5cf9..d62b05c45 100644
--- a/controller/feedcontroller.php
+++ b/controller/feedcontroller.php
@@ -118,13 +118,14 @@ class FeedController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param string $url
- * @param int $parentFolderId
- * @param string $title
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $url
+ * @param int $parentFolderId
+ * @param string $title
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($url, $parentFolderId, $title){
try {
// we need to purge deleted feeds if a feed is created to
@@ -150,28 +151,33 @@ class FeedController extends Controller {
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY);
}
+
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function delete($feedId){
try {
$this->feedService->markDeleted($feedId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function update($feedId){
try {
$feed = $this->feedService->update($feedId, $this->userId);
@@ -190,43 +196,51 @@ class FeedController extends Controller {
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- * @param int $parentFolderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @param int $parentFolderId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function move($feedId, $parentFolderId){
try {
$this->feedService->move($feedId, $parentFolderId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- * @param string $feedTitle
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @param string $feedTitle
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function rename($feedId, $feedTitle) {
try {
$this->feedService->rename($feedId, $feedTitle, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param array $json
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param array $json
+ * @return array
+ */
public function import($json) {
$feed = $this->feedService->importArticles($json, $this->userId);
@@ -240,12 +254,13 @@ class FeedController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- * @param int $highestItemId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @param int $highestItemId
+ * @return array
+ */
public function read($feedId, $highestItemId){
$this->itemService->readFeed($feedId, $highestItemId, $this->userId);
@@ -260,17 +275,20 @@ class FeedController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function restore($feedId){
try {
$this->feedService->unmarkDeleted($feedId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/folderapicontroller.php b/controller/folderapicontroller.php
index 666f4cfa2..84f1dbdf5 100644
--- a/controller/folderapicontroller.php
+++ b/controller/folderapicontroller.php
@@ -58,13 +58,14 @@ class FolderApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param string $name
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param string $name
+ * @return array|mixed|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($name) {
try {
$this->folderService->purgeDeleted($this->userId, false);
@@ -79,29 +80,33 @@ class FolderApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function delete($folderId) {
try {
$this->folderService->delete($folderId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- * @param int $folderId
- * @param string $name
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ * @param int $folderId
+ * @param string $name
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function update($folderId, $name) {
try {
$this->folderService->rename($folderId, $name, $this->userId);
@@ -113,6 +118,8 @@ class FolderApiController extends ApiController {
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php
index 576fee422..9488a7d6c 100644
--- a/controller/foldercontroller.php
+++ b/controller/foldercontroller.php
@@ -57,26 +57,30 @@ class FolderController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- * @param bool $open
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @param bool $open
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function open($folderId, $open) {
try {
$this->folderService->open($folderId, $open, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param string $folderName
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $folderName
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($folderName) {
try {
// we need to purge deleted folders if a folder is created to
@@ -95,26 +99,30 @@ class FolderController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function delete($folderId) {
try {
$this->folderService->markDeleted($folderId, $this->userId);
} catch (ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param string $folderName
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $folderName
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function rename($folderName, $folderId) {
try {
$folder = $this->folderService->rename($folderId, $folderName,
@@ -129,14 +137,16 @@ class FolderController extends Controller {
} catch (ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- * @param int $highestItemId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @param int $highestItemId
+ * @return array
+ */
public function read($folderId, $highestItemId) {
$this->itemService->readFolder($folderId, $highestItemId, $this->userId);
@@ -144,17 +154,20 @@ class FolderController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function restore($folderId) {
try {
$this->folderService->unmarkDeleted($folderId, $this->userId);
} catch (ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/itemapicontroller.php b/controller/itemapicontroller.php
index 40366a936..ff66de951 100644
--- a/controller/itemapicontroller.php
+++ b/controller/itemapicontroller.php
@@ -39,18 +39,19 @@ class ItemApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $type
- * @param int $id
- * @param bool $getRead
- * @param int $batchSize
- * @param int $offset
- * @param int $oldestFirst
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $type
+ * @param int $id
+ * @param bool $getRead
+ * @param int $batchSize
+ * @param int $offset
+ * @param bool $oldestFirst
+ * @return array|mixed
+ */
public function index($type, $id, $getRead, $batchSize=20, $offset=0,
$oldestFirst=false) {
return $this->serializer->serialize(
@@ -62,15 +63,16 @@ class ItemApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $type
- * @param int $id
- * @param int $lastModified
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $type
+ * @param int $id
+ * @param int $lastModified
+ * @return array|mixed
+ */
public function updated($type, $id, $lastModified=0) {
return $this->serializer->serialize(
$this->itemService->findAllNew($id, $type, $lastModified,
@@ -85,28 +87,32 @@ class ItemApiController extends ApiController {
} catch(ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $itemId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $itemId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function read($itemId) {
return $this->setRead(true, $itemId);
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $itemId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $itemId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function unread($itemId) {
return $this->setRead(false, $itemId);
}
@@ -118,30 +124,34 @@ class ItemApiController extends ApiController {
} catch(ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- * @param string $guidHash
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @param string $guidHash
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function star($feedId, $guidHash) {
return $this->setStarred(true, $feedId, $guidHash);
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- * @param string $guidHash
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @param string $guidHash
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function unstar($feedId, $guidHash) {
return $this->setStarred(false, $feedId, $guidHash);
}
@@ -178,7 +188,7 @@ class ItemApiController extends ApiController {
* @param int[] item ids
*/
public function readMultiple($items) {
- return $this->setMultipleRead(true, $items);
+ $this->setMultipleRead(true, $items);
}
@@ -190,7 +200,7 @@ class ItemApiController extends ApiController {
* @param int[] item ids
*/
public function unreadMultiple($items) {
- return $this->setMultipleRead(false, $items);
+ $this->setMultipleRead(false, $items);
}
@@ -214,7 +224,7 @@ class ItemApiController extends ApiController {
* @param int[] item ids
*/
public function starMultiple($items) {
- return $this->setMultipleStarred(true, $items);
+ $this->setMultipleStarred(true, $items);
}
@@ -226,7 +236,7 @@ class ItemApiController extends ApiController {
* @param int[] item ids
*/
public function unstarMultiple($items) {
- return $this->setMultipleStarred(false, $items);
+ $this->setMultipleStarred(false, $items);
}
diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php
index 30677d9fc..bbfcaeb56 100644
--- a/controller/itemcontroller.php
+++ b/controller/itemcontroller.php
@@ -46,14 +46,15 @@ class ItemController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $type
- * @param int $id
- * @param int $limit
- * @param int $offset
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $type
+ * @param int $id
+ * @param int $limit
+ * @param int $offset
+ * @return array
+ */
public function index($type, $id, $limit=50, $offset=0) {
$showAll = $this->settings->getUserValue($this->userId, $this->appName,
'showAll') === '1';
@@ -92,13 +93,14 @@ class ItemController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $type
- * @param int $id
- * @param int $lastModified
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $type
+ * @param int $id
+ * @param int $lastModified
+ * @return array
+ */
public function newItems($type, $id, $lastModified=0) {
$showAll = $this->settings->getUserValue($this->userId, $this->appName,
'showAll') === '1';
@@ -120,13 +122,14 @@ class ItemController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- * @param string $guidHash
- * @param bool $isStarred
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @param string $guidHash
+ * @param bool $isStarred
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function star($feedId, $guidHash, $isStarred){
try {
$this->itemService->star($feedId, $guidHash, $isStarred,
@@ -134,29 +137,35 @@ class ItemController extends Controller {
} catch(ServiceException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param int $itemId
- * @param bool $isRead
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $itemId
+ * @param bool $isRead
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function read($itemId, $isRead=true){
try {
$this->itemService->read($itemId, $isRead, $this->userId);
} catch(ServiceException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param int $highestItemId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $highestItemId
+ * @return array
+ */
public function readAll($highestItemId){
$this->itemService->readAll($highestItemId, $this->userId);
return ['feeds' => $this->feedService->findAll($this->userId)];
diff --git a/controller/jsonhttperror.php b/controller/jsonhttperror.php
index 962520b6a..9ac8704c5 100644
--- a/