diff options
author | Sean Molenaar <sean@m2mobi.com> | 2018-11-29 20:59:46 +0100 |
---|---|---|
committer | Sean Molenaar <sean@m2mobi.com> | 2018-12-14 07:54:43 +0100 |
commit | becce6b7520912257c3d72697a3aefec9923a467 (patch) | |
tree | a2e0da34df11ade7c630e9b681fac6d3b2383918 /lib/Controller | |
parent | 0f2645145ac31ad77788954c513f391bc4fbb295 (diff) |
Define an official codestyle and adhere to it.
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/AdminController.php | 76 | ||||
-rw-r--r-- | lib/Controller/ApiController.php | 10 | ||||
-rw-r--r-- | lib/Controller/EntityApiSerializer.php | 20 | ||||
-rw-r--r-- | lib/Controller/ExportController.php | 13 | ||||
-rw-r--r-- | lib/Controller/FeedApiController.php | 48 | ||||
-rw-r--r-- | lib/Controller/FeedController.php | 73 | ||||
-rw-r--r-- | lib/Controller/FolderApiController.php | 30 | ||||
-rw-r--r-- | lib/Controller/FolderController.php | 50 | ||||
-rw-r--r-- | lib/Controller/ItemApiController.php | 80 | ||||
-rw-r--r-- | lib/Controller/ItemController.php | 82 | ||||
-rw-r--r-- | lib/Controller/JSONHttpError.php | 7 | ||||
-rw-r--r-- | lib/Controller/PageController.php | 61 | ||||
-rw-r--r-- | lib/Controller/UserApiController.php | 6 | ||||
-rw-r--r-- | lib/Controller/UtilityApiController.php | 14 |
14 files changed, 312 insertions, 258 deletions
diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index 7feff907b..3ce09a0d1 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -28,9 +28,9 @@ use OCA\News\Service\ItemService; */ class AdminController extends Controller { - private $_config; - private $_configPath; - private $_itemService; + private $config; + private $configPath; + private $itemService; /** * AdminController constructor. @@ -41,13 +41,17 @@ class AdminController extends Controller * @param ItemService $itemService Service for items * @param string $configFile Path to the config */ - public function __construct($appName, IRequest $request, Config $config, - ItemService $itemService, $configFile + public function __construct( + $appName, + IRequest $request, + Config $config, + ItemService $itemService, + $configFile ) { parent::__construct($appName, $request); - $this->_config = $config; - $this->_configPath = $configFile; - $this->_itemService = $itemService; + $this->config = $config; + $this->configPath = $configFile; + $this->itemService = $itemService; } /** @@ -62,13 +66,13 @@ class AdminController extends Controller { $data = [ 'autoPurgeMinimumInterval' => - $this->_config->getAutoPurgeMinimumInterval(), - 'autoPurgeCount' => $this->_config->getAutoPurgeCount(), - 'maxRedirects' => $this->_config->getMaxRedirects(), - 'feedFetcherTimeout' => $this->_config->getFeedFetcherTimeout(), - 'useCronUpdates' => $this->_config->getUseCronUpdates(), - 'maxSize' => $this->_config->getMaxSize(), - 'exploreUrl' => $this->_config->getExploreUrl(), + $this->config->getAutoPurgeMinimumInterval(), + 'autoPurgeCount' => $this->config->getAutoPurgeCount(), + 'maxRedirects' => $this->config->getMaxRedirects(), + 'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), + 'useCronUpdates' => $this->config->getUseCronUpdates(), + 'maxSize' => $this->config->getMaxSize(), + 'exploreUrl' => $this->config->getExploreUrl(), ]; return new TemplateResponse($this->appName, 'admin', $data, 'blank'); } @@ -87,29 +91,33 @@ class AdminController extends Controller * * @return array with the updated values */ - public function update($autoPurgeMinimumInterval, $autoPurgeCount, - $maxRedirects, $feedFetcherTimeout, $maxSize, - $useCronUpdates, $exploreUrl + public function update( + $autoPurgeMinimumInterval, + $autoPurgeCount, + $maxRedirects, + $feedFetcherTimeout, + $maxSize, + $useCronUpdates, + $exploreUrl ) { - $this->_config->setAutoPurgeMinimumInterval($autoPurgeMinimumInterval); - $this->_config->setAutoPurgeCount($autoPurgeCount); - $this->_config->setMaxRedirects($maxRedirects); - $this->_config->setMaxSize($maxSize); - $this->_config->setFeedFetcherTimeout($feedFetcherTimeout); - $this->_config->setUseCronUpdates($useCronUpdates); - $this->_config->setExploreUrl($exploreUrl); - $this->_config->write($this->_configPath); + $this->config->setAutoPurgeMinimumInterval($autoPurgeMinimumInterval); + $this->config->setAutoPurgeCount($autoPurgeCount); + $this->config->setMaxRedirects($maxRedirects); + $this->config->setMaxSize($maxSize); + $this->config->setFeedFetcherTimeout($feedFetcherTimeout); + $this->config->setUseCronUpdates($useCronUpdates); + $this->config->setExploreUrl($exploreUrl); + $this->config->write($this->configPath); return [ 'autoPurgeMinimumInterval' => - $this->_config->getAutoPurgeMinimumInterval(), - 'autoPurgeCount' => $this->_config->getAutoPurgeCount(), - 'maxRedirects' => $this->_config->getMaxRedirects(), - 'maxSize' => $this->_config->getMaxSize(), - 'feedFetcherTimeout' => $this->_config->getFeedFetcherTimeout(), - 'useCronUpdates' => $this->_config->getUseCronUpdates(), - 'exploreUrl' => $this->_config->getExploreUrl(), + $this->config->getAutoPurgeMinimumInterval(), + 'autoPurgeCount' => $this->config->getAutoPurgeCount(), + 'maxRedirects' => $this->config->getMaxRedirects(), + 'maxSize' => $this->config->getMaxSize(), + 'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), + 'useCronUpdates' => $this->config->getUseCronUpdates(), + 'exploreUrl' => $this->config->getExploreUrl(), ]; } - } diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index d2a787a28..68caf9236 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -40,7 +40,8 @@ class ApiController extends BaseApiController * @param IRequest $request The request * @param IUserSession $userSession The user session */ - public function __construct($appName, IRequest $request, IUserSession $userSession) { + public function __construct($appName, IRequest $request, IUserSession $userSession) + { parent::__construct($appName, $request); $this->userSession = $userSession; } @@ -48,14 +49,16 @@ class ApiController extends BaseApiController /** * @return IUser */ - protected function getUser() { + protected function getUser() + { return $this->userSession->getUser(); } /** * @return string */ - protected function getUserId() { + protected function getUserId() + { return $this->getUser()->getUID(); } @@ -74,5 +77,4 @@ class ApiController extends BaseApiController 'apiLevels' => ['v1-2'] ]; } - } diff --git a/lib/Controller/EntityApiSerializer.php b/lib/Controller/EntityApiSerializer.php index f624eb84c..78a9b1031 100644 --- a/lib/Controller/EntityApiSerializer.php +++ b/lib/Controller/EntityApiSerializer.php @@ -13,13 +13,12 @@ namespace OCA\News\Controller; use \OCA\News\Db\IAPI; - class EntityApiSerializer { private $level; - public function __construct($level) + public function __construct($level) { $this->level = $level; } @@ -35,16 +34,16 @@ class EntityApiSerializer * * Response * @return array|mixed */ - public function serialize($data) + public function serialize($data) { - if($data instanceof IAPI) { + if ($data instanceof IAPI) { return [$this->level => [$data->toAPI()]]; } - if(is_array($data) && array_key_exists($this->level, $data)) { + if (is_array($data) && array_key_exists($this->level, $data)) { $data[$this->level] = $this->convert($data[$this->level]); - } elseif(is_array($data)) { + } elseif (is_array($data)) { $data = [$this->level => $this->convert($data)]; } @@ -52,12 +51,12 @@ class EntityApiSerializer } - private function convert($entities) + private function convert($entities) { $converted = []; - foreach($entities as $entity) { - if($entity instanceof IAPI) { + foreach ($entities as $entity) { + if ($entity instanceof IAPI) { $converted[] = $entity->toAPI(); // break if it contains anything else than entities @@ -68,5 +67,4 @@ class EntityApiSerializer return $converted; } - -}
\ No newline at end of file +} diff --git a/lib/Controller/ExportController.php b/lib/Controller/ExportController.php index 07ce06f45..16bdfbd4e 100644 --- a/lib/Controller/ExportController.php +++ b/lib/Controller/ExportController.php @@ -33,7 +33,8 @@ class ExportController extends Controller private $itemService; private $userId; - public function __construct($appName, + public function __construct( + $appName, IRequest $request, FolderService $folderService, FeedService $feedService, @@ -60,7 +61,7 @@ class ExportController extends Controller $folders = $this->folderService->findAll($this->userId); $opml = $this->opmlExporter->build($folders, $feeds)->saveXML(); $date = date('Y-m-d'); - $name = "subscriptions-".$date.".opml"; + $name = "subscriptions-" . $date . ".opml"; $mimeType = 'text/xml'; return new TextDownloadResponse($opml, $name, $mimeType); } @@ -77,12 +78,12 @@ class ExportController extends Controller // build assoc array for fast access $feedsDict = []; - foreach($feeds as $feed) { + foreach ($feeds as $feed) { $feedsDict['feed' . $feed->getId()] = $feed; } $articles = []; - foreach($items as $item) { + foreach ($items as $item) { $articles[] = $item->toExport($feedsDict); } @@ -93,6 +94,4 @@ class ExportController extends Controller ); return $response; } - - -}
\ No newline at end of file +} diff --git a/lib/Controller/FeedApiController.php b/lib/Controller/FeedApiController.php index 2e4a85eef..160a8bcd6 100644 --- a/lib/Controller/FeedApiController.php +++ b/lib/Controller/FeedApiController.php @@ -25,10 +25,8 @@ use \OCA\News\Service\ItemService; use \OCA\News\Service\ServiceNotFoundException; use \OCA\News\Service\ServiceConflictException; - class FeedApiController extends ApiController { - use JSONHttpError; private $itemService; @@ -37,7 +35,8 @@ class FeedApiController extends ApiController private $loggerParams; private $serializer; - public function __construct($appName, + public function __construct( + $appName, IRequest $request, IUserSession $userSession, FeedService $feedService, @@ -59,7 +58,7 @@ class FeedApiController extends ApiController * @NoCSRFRequired * @CORS */ - public function index() + public function index() { $result = [ @@ -73,7 +72,7 @@ class FeedApiController extends ApiController $this->itemService->getNewestItemId($this->getUserId()); // in case there are no items, ignore - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { } return $this->serializer->serialize($result); @@ -89,7 +88,7 @@ class FeedApiController extends ApiController * @param int $folderId * @return array|mixed|\OCP\AppFramework\Http\JSONResponse */ - public function create($url, $folderId=0) + public function create($url, $folderId = 0) { try { $this->feedService->purgeDeleted($this->getUserId(), false); @@ -102,14 +101,13 @@ class FeedApiController extends ApiController $this->itemService->getNewestItemId($this->getUserId()); // in case there are no items, ignore - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { } return $this->serializer->serialize($result); - - } catch(ServiceConflictException $ex) { + } catch (ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } } @@ -123,11 +121,11 @@ class FeedApiController extends ApiController * @param int $feedId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function delete($feedId) + public function delete($feedId) { try { $this->feedService->delete($feedId, $this->getUserId()); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -143,7 +141,7 @@ class FeedApiController extends ApiController * @param int $feedId * @param int $newestItemId */ - public function read($feedId, $newestItemId) + public function read($feedId, $newestItemId) { $this->itemService->readFeed($feedId, $newestItemId, $this->getUserId()); } @@ -158,13 +156,15 @@ class FeedApiController extends ApiController * @param int $folderId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function move($feedId, $folderId) + public function move($feedId, $folderId) { try { $this->feedService->patch( - $feedId, $this->getUserId(), ['folderId' => $folderId] + $feedId, + $this->getUserId(), + ['folderId' => $folderId] ); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -181,13 +181,15 @@ class FeedApiController extends ApiController * @param string $feedTitle * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function rename($feedId, $feedTitle) + public function rename($feedId, $feedTitle) { try { $this->feedService->patch( - $feedId, $this->getUserId(), ['title' => $feedTitle] + $feedId, + $this->getUserId(), + ['title' => $feedTitle] ); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -199,7 +201,7 @@ class FeedApiController extends ApiController * @NoCSRFRequired * @CORS */ - public function fromAllUsers() + public function fromAllUsers() { $feeds = $this->feedService->findAllFromAllUsers(); $result = ['feeds' => []]; @@ -221,18 +223,16 @@ class FeedApiController extends ApiController * @param string $userId * @param int $feedId */ - public function update($userId, $feedId) + public function update($userId, $feedId) { try { $this->feedService->update($feedId, $userId); // ignore update failure - } catch(\Exception $ex) { + } catch (\Exception $ex) { $this->logger->debug( 'Could not update feed ' . $ex->getMessage(), $this->loggerParams ); } } - - } diff --git a/lib/Controller/FeedController.php b/lib/Controller/FeedController.php index cf323b58e..dbb36bb02 100644 --- a/lib/Controller/FeedController.php +++ b/lib/Controller/FeedController.php @@ -25,10 +25,8 @@ use OCA\News\Service\ServiceNotFoundException; use OCA\News\Service\ServiceConflictException; use OCA\News\Db\FeedType; - class FeedController extends Controller { - use JSONHttpError; private $feedService; @@ -37,7 +35,8 @@ class FeedController extends Controller private $userId; private $settings; - public function __construct($appName, + public function __construct( + $appName, IRequest $request, FolderService $folderService, FeedService $feedService, @@ -88,32 +87,32 @@ class FeedController extends Controller { $feedId = (int) $this->settings->getUserValue( $this->userId, - $this->appName, 'lastViewedFeedId' + $this->appName, + 'lastViewedFeedId' ); $feedType = $this->settings->getUserValue( - $this->userId, $this->appName, + $this->userId, + $this->appName, 'lastViewedFeedType' ); // cast from null to int is 0 - if($feedType !== null) { + if ($feedType !== null) { $feedType = (int) $feedType; } // check if feed or folder exists try { - if($feedType === FeedType::FOLDER) { + if ($feedType === FeedType::FOLDER) { $this->folderService->find($feedId, $this->userId); - } elseif ($feedType === FeedType::FEED) { $this->feedService->find($feedId, $this->userId); // if its the first launch, those values will be null - } elseif($feedType === null) { + } elseif ($feedType === null) { throw new ServiceNotFoundException(''); } - - } catch (ServiceNotFoundException $ex){ + } catch (ServiceNotFoundException $ex) { $feedId = 0; $feedType = FeedType::SUBSCRIPTIONS; } @@ -137,8 +136,12 @@ class FeedController extends Controller * @param string $password * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function create($url, $parentFolderId, $title=null, - $user=null, $password=null + public function create( + $url, + $parentFolderId, + $title = null, + $user = null, + $password = null ) { try { // we need to purge deleted feeds if a feed is created to @@ -146,9 +149,12 @@ class FeedController extends Controller $this->feedService->purgeDeleted($this->userId, false); $feed = $this->feedService->create( - $url, $parentFolderId, - $this->userId, $title, - $user, $password + $url, + $parentFolderId, + $this->userId, + $title, + $user, + $password ); $params = ['feeds' => [$feed]]; @@ -162,13 +168,11 @@ class FeedController extends Controller } return $params; - - } catch(ServiceConflictException $ex) { + } catch (ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } - } @@ -182,7 +186,7 @@ class FeedController extends Controller { try { $this->feedService->markDeleted($feedId, $this->userId); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -211,11 +215,9 @@ class FeedController extends Controller ] ] ]; - - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } - } @@ -225,7 +227,7 @@ class FeedController extends Controller * @param array $json * @return array */ - public function import($json) + public function import($json) { $feed = $this->feedService->importArticles($json, $this->userId); @@ -233,7 +235,7 @@ class FeedController extends Controller 'starred' => $this->itemService->starredCount($this->userId) ]; - if($feed) { + if ($feed) { $params['feeds'] = [$feed]; } @@ -273,7 +275,7 @@ class FeedController extends Controller { try { $this->feedService->unmarkDeleted($feedId, $this->userId); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -291,9 +293,14 @@ class FeedController extends Controller * @param int $folderId * @param string $title */ - public function patch($feedId, $pinned=null, $fullTextEnabled=null, - $updateMode=null, $ordering=null, $title=null, - $folderId=null + public function patch( + $feedId, + $pinned = null, + $fullTextEnabled = null, + $updateMode = null, + $ordering = null, + $title = null, + $folderId = null ) { $attributes = [ 'pinned' => $pinned, @@ -305,18 +312,18 @@ class FeedController extends Controller ]; $diff = array_filter( - $attributes, function ($value) { + $attributes, + function ($value) { return $value !== null; } ); try { $this->feedService->patch($feedId, $this->userId, $diff); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } return []; } - } diff --git a/lib/Controller/FolderApiController.php b/lib/Controller/FolderApiController.php index 348fefda6..eb98b8107 100644 --- a/lib/Controller/FolderApiController.php +++ b/lib/Controller/FolderApiController.php @@ -25,17 +25,16 @@ use \OCA\News\Service\ServiceNotFoundException; use \OCA\News\Service\ServiceConflictException; use \OCA\News\Service\ServiceValidationException; - class FolderApiController extends ApiController { - use JSONHttpError; private $folderService; private $itemService; private $serializer; - public function __construct($appName, + public function __construct( + $appName, IRequest $request, IUserSession $userSession, FolderService $folderService, @@ -53,7 +52,7 @@ class FolderApiController extends ApiController * @NoCSRFRequired * @CORS */ - public function index() + public function index() { return $this->serializer->serialize( $this->folderService->findAll($this->getUserId()) @@ -69,16 +68,16 @@ class FolderApiController extends ApiController * @param string $name * @return array|mixed|\OCP\AppFramework\Http\JSONResponse */ - public function create($name) + public function create($name) { try { $this->folderService->purgeDeleted($this->getUserId(), false); return $this->serializer->serialize( $this->folderService->create($name, $this->getUserId()) ); - } catch(ServiceValidationException $ex) { + } catch (ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); - } catch(ServiceConflictException $ex) { + } catch (ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); } } @@ -92,11 +91,11 @@ class FolderApiController extends ApiController * @param int $folderId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function delete($folderId) + public function delete($folderId) { try { $this->folderService->delete($folderId, $this->getUserId()); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -112,16 +111,15 @@ class FolderApiController extends ApiController * @param string $name * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function update($folderId, $name) + public function update($folderId, $name) { try { $this->folderService->rename($folderId, $name, $this->getUserId()); - - } catch(ServiceValidationException $ex) { + } catch (ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); - } catch(ServiceConflictException $ex) { + } catch (ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -137,10 +135,8 @@ class FolderApiController extends ApiController * @param int $folderId * @param int $newestItemId */ - public function read($folderId, $newestItemId) + public function read($folderId, $newestItemId) { $this->itemService->readFolder($folderId, $newestItemId, $this->getUserId()); } - - } diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 8b4dadcca..d3089178d 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -24,10 +24,8 @@ use \OCA\News\Service\ServiceNotFoundException; use \OCA\News\Service\ServiceConflictException; use \OCA\News\Service\ServiceValidationException; - class FolderController extends Controller { - use JSONHttpError; private $folderService; @@ -35,7 +33,8 @@ class FolderController extends Controller private $itemService; private $userId; - public function __construct($appName, + public function __construct( + $appName, IRequest $request, FolderService $folderService, FeedService $feedService, @@ -53,7 +52,7 @@ class FolderController extends Controller /** * @NoAdminRequired */ - public function index() + public function index() { $folders = $this->folderService->findAll($this->userId); return ['folders' => $folders]; @@ -67,11 +66,11 @@ class FolderController extends Controller * @param bool $open * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function open($folderId, $open) + public function open($folderId, $open) { try { $this->folderService->open($folderId, $open, $this->userId); - } catch(ServiceNotFoundException $ex) { + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -85,7 +84,7 @@ class FolderController extends Controller * @param string $folderName * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function create($folderName) + public function create($folderName) { try { // we need to purge deleted folders if a folder is created to @@ -94,13 +93,11 @@ class FolderController extends Controller $folder = $this->folderService->create($folderName, $this->userId); return ['folders' => [$folder]]; - - } catch(ServiceConflictException $ex) { + } catch (ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(ServiceValidationException $ex) { + } catch (ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); } - } @@ -110,11 +107,11 @@ class FolderController extends Controller * @param int $folderId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function delete($folderId) + public function delete($folderId) { try { $this->folderService->markDeleted($folderId, $this->userId); - } catch (ServiceNotFoundException $ex){ + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -129,24 +126,23 @@ class FolderController extends Controller * @param int $folderId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function rename($folderName, $folderId) + public function rename($folderName, $folderId) { try { $folder = $this->folderService->rename( - $folderId, $folderName, + $folderId, + $folderName, $this->userId ); return ['folders' => [$folder]]; - - } catch(ServiceConflictException $ex) { + } catch (ServiceConflictException $ex) { return $this->error($ex, Http::STATUS_CONFLICT); - } catch(ServiceValidationException $ex) { + } catch (ServiceValidationException $ex) { return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); - } catch (ServiceNotFoundException $ex){ + } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } - } /** @@ -156,10 +152,12 @@ class FolderController extends Controller * @param int $highestItemId * @return array */ - public function read($folderId, $highestItemId) |