From 5b94705cf3918dc7986c6043b1fbe776bf22958f Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 27 Mar 2018 15:35:06 +0200 Subject: Core: Fix compatibility with nextcloud codestyle (#280) --- lib/Controller/AdminController.php | 121 +++++++++++++++++++------------ lib/Controller/ApiController.php | 30 ++++++-- lib/Controller/EntityApiSerializer.php | 28 ++++---- lib/Controller/ExportController.php | 40 ++++++----- lib/Controller/FeedApiController.php | 76 ++++++++++++-------- lib/Controller/FeedController.php | 123 +++++++++++++++++++------------- lib/Controller/FolderApiController.php | 41 ++++++----- lib/Controller/FolderController.php | 57 +++++++++------ lib/Controller/ItemApiController.php | 91 ++++++++++++++--------- lib/Controller/ItemController.php | 108 ++++++++++++++++------------ lib/Controller/JSONHttpError.php | 12 ++-- lib/Controller/PageController.php | 68 +++++++++++------- lib/Controller/UserApiController.php | 25 ++++--- lib/Controller/UtilityApiController.php | 42 ++++++----- 14 files changed, 518 insertions(+), 344 deletions(-) (limited to 'lib/Controller') diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index e5cd55711..7feff907b 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -7,8 +7,9 @@ * * @author Alessandro Cosentino * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -20,68 +21,94 @@ use OCP\AppFramework\Controller; use OCA\News\Config\Config; use OCA\News\Service\ItemService; -class AdminController extends Controller { - - private $config; - private $configPath; - private $itemService; +/** + * Class AdminController + * + * @package OCA\News\Controller + */ +class AdminController extends Controller +{ + private $_config; + private $_configPath; + private $_itemService; - public function __construct($AppName, IRequest $request, Config $config, - ItemService $itemService, $configFile){ - parent::__construct($AppName, $request); - $this->config = $config; - $this->configPath = $configFile; - $this->itemService = $itemService; + /** + * AdminController constructor. + * + * @param string $appName The name of the app + * @param IRequest $request The request + * @param Config $config Config for nextcloud + * @param ItemService $itemService Service for items + * @param string $configFile Path to the config + */ + public function __construct($appName, IRequest $request, Config $config, + ItemService $itemService, $configFile + ) { + parent::__construct($appName, $request); + $this->_config = $config; + $this->_configPath = $configFile; + $this->_itemService = $itemService; } - // There are no checks for the index method since the output is rendered - // in admin/admin.php - public function index() { + /** + * Controller main entry. + * + * There are no checks for the index method since the output is + * rendered in admin/admin.php + * + * @return TemplateResponse + */ + public function index() + { $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'); } /** - * @param int $autoPurgeMinimumInterval - * @param int $autoPurgeCount - * @param int $maxRedirects - * @param int $feedFetcherTimeout - * @param int $maxSize - * @param bool $useCronUpdates - * @param string $exploreUrl + * Update the app config. + * + * @param int $autoPurgeMinimumInterval New minimum interval for auto-purge + * @param int $autoPurgeCount New value of auto-purge count + * @param int $maxRedirects New value for max amount of redirects + * @param int $feedFetcherTimeout New timeout value for feed fetcher + * @param int $maxSize New max feed size + * @param bool $useCronUpdates Whether or not to use cron updates + * @param string $exploreUrl URL to use for the explore feed + * * @return array with the updated values */ 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); + $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); 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 d16c6438d..f5052b49a 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -7,8 +7,8 @@ * * @author Alessandro Cosentino * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -16,19 +16,35 @@ namespace OCA\News\Controller; use OCP\IRequest; use OCP\AppFramework\ApiController as BaseApiController; -class ApiController extends BaseApiController { - - public function __construct($appName, - IRequest $request){ +/** + * Class ApiController + * + * @package OCA\News\Controller + */ +class ApiController extends BaseApiController +{ + /** + * ApiController constructor. + * + * @param string $appName The name of the app + * @param IRequest $request The request + */ + public function __construct($appName, IRequest $request) + { parent::__construct($appName, $request); } /** + * Indication of the API levels + * * @PublicPage * @NoCSRFRequired * @CORS + * + * @return array */ - public function index() { + public function index() + { return [ 'apiLevels' => ['v1-2'] ]; diff --git a/lib/Controller/EntityApiSerializer.php b/lib/Controller/EntityApiSerializer.php index af126045e..f624eb84c 100644 --- a/lib/Controller/EntityApiSerializer.php +++ b/lib/Controller/EntityApiSerializer.php @@ -5,8 +5,8 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt - * @copyright Bernhard Posselt 2014 + * @author Bernhard Posselt + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -14,11 +14,13 @@ namespace OCA\News\Controller; use \OCA\News\Db\IAPI; -class EntityApiSerializer { +class EntityApiSerializer +{ private $level; - public function __construct($level) { + public function __construct($level) + { $this->level = $level; } @@ -26,14 +28,15 @@ class EntityApiSerializer { /** * Call toAPI() method on all entities. Works on * - * @param mixed $data : - * * Entity - * * Entity[] - * * array('level' => Entity[]) - * * Response + * @param mixed $data : + * * Entity + * * Entity[] + * * array('level' => Entity[]) + * * Response * @return array|mixed */ - public function serialize($data) { + public function serialize($data) + { if($data instanceof IAPI) { return [$this->level => [$data->toAPI()]]; @@ -49,14 +52,15 @@ class EntityApiSerializer { } - private function convert($entities) { + private function convert($entities) + { $converted = []; foreach($entities as $entity) { if($entity instanceof IAPI) { $converted[] = $entity->toAPI(); - // break if it contains anything else than entities + // break if it contains anything else than entities } else { return $entities; } diff --git a/lib/Controller/ExportController.php b/lib/Controller/ExportController.php index 11060f075..1ce81963d 100644 --- a/lib/Controller/ExportController.php +++ b/lib/Controller/ExportController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -24,7 +24,8 @@ use \OCA\News\Service\FeedService; use \OCA\News\Service\ItemService; use \OCA\News\Utility\OPMLExporter; -class ExportController extends Controller { +class ExportController extends Controller +{ private $opmlExporter; private $folderService; @@ -32,14 +33,15 @@ class ExportController extends Controller { private $itemService; private $userId; - public function __construct($AppName, - IRequest $request, - FolderService $folderService, - FeedService $feedService, - ItemService $itemService, - OPMLExporter $opmlExporter, - $UserId){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + FolderService $folderService, + FeedService $feedService, + ItemService $itemService, + OPMLExporter $opmlExporter, + $UserId + ) { + parent::__construct($appName, $request); $this->feedService = $feedService; $this->folderService = $folderService; $this->opmlExporter = $opmlExporter; @@ -52,7 +54,8 @@ class ExportController extends Controller { * @NoAdminRequired * @NoCSRFRequired */ - public function opml(){ + public function opml() + { $feeds = $this->feedService->findAll($this->userId); $folders = $this->folderService->findAll($this->userId); $opml = $this->opmlExporter->build($folders, $feeds)->saveXML(); @@ -66,7 +69,8 @@ class ExportController extends Controller { * @NoAdminRequired * @NoCSRFRequired */ - public function articles(){ + public function articles() + { $feeds = $this->feedService->findAll($this->userId); $items = $this->itemService->getUnreadOrStarred($this->userId); @@ -82,8 +86,10 @@ class ExportController extends Controller { } $response = new JSONResponse($articles); - $response->addHeader('Content-Disposition', - 'attachment; filename="articles.json"'); + $response->addHeader( + 'Content-Disposition', + 'attachment; filename="articles.json"' + ); return $response; } diff --git a/lib/Controller/FeedApiController.php b/lib/Controller/FeedApiController.php index eb57198d8..344d72bd0 100644 --- a/lib/Controller/FeedApiController.php +++ b/lib/Controller/FeedApiController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -23,7 +23,8 @@ use \OCA\News\Service\ServiceNotFoundException; use \OCA\News\Service\ServiceConflictException; -class FeedApiController extends ApiController { +class FeedApiController extends ApiController +{ use JSONHttpError; @@ -34,14 +35,15 @@ class FeedApiController extends ApiController { private $loggerParams; private $serializer; - public function __construct($AppName, - IRequest $request, - FeedService $feedService, - ItemService $itemService, - ILogger $logger, - $UserId, - $LoggerParameters){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + FeedService $feedService, + ItemService $itemService, + ILogger $logger, + $UserId, + $LoggerParameters + ) { + parent::__construct($appName, $request); $this->feedService = $feedService; $this->itemService = $itemService; $this->userId = $UserId; @@ -56,7 +58,8 @@ class FeedApiController extends ApiController { * @NoCSRFRequired * @CORS */ - public function index() { + public function index() + { $result = [ 'starredCount' => $this->itemService->starredCount($this->userId), @@ -68,8 +71,9 @@ class FeedApiController extends ApiController { $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId); - // in case there are no items, ignore - } catch(ServiceNotFoundException $ex) {} + // in case there are no items, ignore + } catch(ServiceNotFoundException $ex) { + } return $this->serializer->serialize($result); } @@ -81,10 +85,11 @@ class FeedApiController extends ApiController { * @CORS * * @param string $url - * @param int $folderId + * @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->userId, false); @@ -95,8 +100,9 @@ class FeedApiController extends ApiController { $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId); - // in case there are no items, ignore - } catch(ServiceNotFoundException $ex) {} + // in case there are no items, ignore + } catch(ServiceNotFoundException $ex) { + } return $this->serializer->serialize($result); @@ -116,7 +122,8 @@ 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->userId); } catch(ServiceNotFoundException $ex) { @@ -135,7 +142,8 @@ 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->userId); } @@ -149,7 +157,8 @@ 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->userId, ['folderId' => $folderId] @@ -167,11 +176,12 @@ class FeedApiController extends ApiController { * @NoCSRFRequired * @CORS * - * @param int $feedId + * @param int $feedId * @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->userId, ['title' => $feedTitle] @@ -188,7 +198,8 @@ class FeedApiController extends ApiController { * @NoCSRFRequired * @CORS */ - public function fromAllUsers() { + public function fromAllUsers() + { $feeds = $this->feedService->findAllFromAllUsers(); $result = ['feeds' => []]; @@ -207,15 +218,18 @@ class FeedApiController extends ApiController { * @NoCSRFRequired * * @param string $userId - * @param int $feedId + * @param int $feedId */ - public function update($userId, $feedId) { + public function update($userId, $feedId) + { try { $this->feedService->update($feedId, $userId); - // ignore update failure + // ignore update failure } catch(\Exception $ex) { - $this->logger->debug('Could not update feed ' . $ex->getMessage(), - $this->loggerParams); + $this->logger->debug( + 'Could not update feed ' . $ex->getMessage(), + $this->loggerParams + ); } } diff --git a/lib/Controller/FeedController.php b/lib/Controller/FeedController.php index fecd58398..cf323b58e 100644 --- a/lib/Controller/FeedController.php +++ b/lib/Controller/FeedController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -26,7 +26,8 @@ use OCA\News\Service\ServiceConflictException; use OCA\News\Db\FeedType; -class FeedController extends Controller { +class FeedController extends Controller +{ use JSONHttpError; @@ -36,14 +37,15 @@ class FeedController extends Controller { private $userId; private $settings; - public function __construct($AppName, - IRequest $request, - FolderService $folderService, - FeedService $feedService, - ItemService $itemService, - IConfig $settings, - $UserId){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + FolderService $folderService, + FeedService $feedService, + ItemService $itemService, + IConfig $settings, + $UserId + ) { + parent::__construct($appName, $request); $this->feedService = $feedService; $this->folderService = $folderService; $this->itemService = $itemService; @@ -55,7 +57,8 @@ class FeedController extends Controller { /** * @NoAdminRequired */ - public function index(){ + public function index() + { // this method is also used to update the interface // because of this we also pass the starred count and the newest @@ -69,9 +72,10 @@ class FeedController extends Controller { $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId); - // An exception occurs if there is a newest item. If there is none, - // simply ignore it and do not add the newestItemId - } catch (ServiceNotFoundException $ex) {} + // An exception occurs if there is a newest item. If there is none, + // simply ignore it and do not add the newestItemId + } catch (ServiceNotFoundException $ex) { + } return $params; } @@ -80,27 +84,32 @@ class FeedController extends Controller { /** * @NoAdminRequired */ - public function active(){ - $feedId = (int) $this->settings->getUserValue($this->userId, - $this->appName,'lastViewedFeedId'); - $feedType = $this->settings->getUserValue($this->userId, $this->appName, - 'lastViewedFeedType'); + public function active() + { + $feedId = (int) $this->settings->getUserValue( + $this->userId, + $this->appName, 'lastViewedFeedId' + ); + $feedType = $this->settings->getUserValue( + $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){ + } elseif ($feedType === FeedType::FEED) { $this->feedService->find($feedId, $this->userId); - // if its the first launch, those values will be null - } elseif($feedType === null){ + // if its the first launch, those values will be null + } elseif($feedType === null) { throw new ServiceNotFoundException(''); } @@ -122,31 +131,35 @@ class FeedController extends Controller { * @NoAdminRequired * * @param string $url - * @param int $parentFolderId + * @param int $parentFolderId * @param string $title * @param string $user * @param string $password * @return array|\OCP\AppFramework\Http\JSONResponse */ public function create($url, $parentFolderId, $title=null, - $user=null, $password=null){ + $user=null, $password=null + ) { try { // we need to purge deleted feeds if a feed is created to // prevent already exists exceptions $this->feedService->purgeDeleted($this->userId, false); - $feed = $this->feedService->create($url, $parentFolderId, - $this->userId, $title, - $user, $password); + $feed = $this->feedService->create( + $url, $parentFolderId, + $this->userId, $title, + $user, $password + ); $params = ['feeds' => [$feed]]; try { $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId); - // An exception occurs if there is a newest item. If there is none, - // simply ignore it and do not add the newestItemId - } catch (ServiceNotFoundException $ex) {} + // An exception occurs if there is a newest item. If there is none, + // simply ignore it and do not add the newestItemId + } catch (ServiceNotFoundException $ex) { + } return $params; @@ -165,7 +178,8 @@ class FeedController extends Controller { * @param int $feedId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function delete($feedId){ + public function delete($feedId) + { try { $this->feedService->markDeleted($feedId, $this->userId); } catch(ServiceNotFoundException $ex) { @@ -182,7 +196,8 @@ class FeedController extends Controller { * @param int $feedId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function update($feedId){ + public function update($feedId) + { try { $feed = $this->feedService->update($feedId, $this->userId); @@ -210,7 +225,8 @@ class FeedController extends Controller { * @param array $json * @return array */ - public function import($json) { + public function import($json) + { $feed = $this->feedService->importArticles($json, $this->userId); $params = [ @@ -232,7 +248,8 @@ class FeedController extends Controller { * @param int $highestItemId * @return array */ - public function read($feedId, $highestItemId){ + public function read($feedId, $highestItemId) + { $this->itemService->readFeed($feedId, $highestItemId, $this->userId); return [ @@ -252,7 +269,8 @@ class FeedController extends Controller { * @param int $feedId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function restore($feedId){ + public function restore($feedId) + { try { $this->feedService->unmarkDeleted($feedId, $this->userId); } catch(ServiceNotFoundException $ex) { @@ -265,17 +283,18 @@ class FeedController extends Controller { /** * @NoAdminRequired * - * @param int $feedId - * @param bool $pinned - * @param bool $fullTextEnabled - * @param int $updateMode - * @param int $ordering - * @param int $folderId + * @param int $feedId + * @param bool $pinned + * @param bool $fullTextEnabled + * @param int $updateMode + * @param int $ordering + * @param int $folderId * @param string $title */ public function patch($feedId, $pinned=null, $fullTextEnabled=null, - $updateMode=null, $ordering=null, $title=null, - $folderId=null) { + $updateMode=null, $ordering=null, $title=null, + $folderId=null + ) { $attributes = [ 'pinned' => $pinned, 'fullTextEnabled' => $fullTextEnabled, @@ -285,9 +304,11 @@ class FeedController extends Controller { 'folderId' => $folderId ]; - $diff = array_filter($attributes, function ($value) { - return $value !== null; - }); + $diff = array_filter( + $attributes, function ($value) { + return $value !== null; + } + ); try { $this->feedService->patch($feedId, $this->userId, $diff); diff --git a/lib/Controller/FolderApiController.php b/lib/Controller/FolderApiController.php index 88385b171..b24ae9acb 100644 --- a/lib/Controller/FolderApiController.php +++ b/lib/Controller/FolderApiController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -23,7 +23,8 @@ use \OCA\News\Service\ServiceConflictException; use \OCA\News\Service\ServiceValidationException; -class FolderApiController extends ApiController { +class FolderApiController extends ApiController +{ use JSONHttpError; @@ -32,12 +33,13 @@ class FolderApiController extends ApiController { private $userId; private $serializer; - public function __construct($AppName, - IRequest $request, - FolderService $folderService, - ItemService $itemService, - $UserId){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + FolderService $folderService, + ItemService $itemService, + $UserId + ) { + parent::__construct($appName, $request); $this->folderService = $folderService; $this->itemService = $itemService; $this->userId = $UserId; @@ -50,7 +52,8 @@ class FolderApiController extends ApiController { * @NoCSRFRequired * @CORS */ - public function index() { + public function index() + { return $this->serializer->serialize( $this->folderService->findAll($this->userId) ); @@ -65,7 +68,8 @@ 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->userId, false); return $this->serializer->serialize( @@ -87,7 +91,8 @@ 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->userId); } catch(ServiceNotFoundException $ex) { @@ -102,11 +107,12 @@ class FolderApiController extends ApiController { * @NoAdminRequired * @NoCSRFRequired * @CORS - * @param int $folderId + * @param int $folderId * @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->userId); @@ -130,7 +136,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->userId); } diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 75faa6550..8b4dadcca 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -25,7 +25,8 @@ use \OCA\News\Service\ServiceConflictException; use \OCA\News\Service\ServiceValidationException; -class FolderController extends Controller { +class FolderController extends Controller +{ use JSONHttpError; @@ -34,13 +35,14 @@ class FolderController extends Controller { private $itemService; private $userId; - public function __construct($AppName, - IRequest $request, - FolderService $folderService, - FeedService $feedService, - ItemService $itemService, - $UserId) { - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + FolderService $folderService, + FeedService $feedService, + ItemService $itemService, + $UserId + ) { + parent::__construct($appName, $request); $this->folderService = $folderService; $this->feedService = $feedService; $this->itemService = $itemService; @@ -51,7 +53,8 @@ class FolderController extends Controller { /** * @NoAdminRequired */ - public function index() { + public function index() + { $folders = $this->folderService->findAll($this->userId); return ['folders' => $folders]; } @@ -60,11 +63,12 @@ class FolderController extends Controller { /** * @NoAdminRequired * - * @param int $folderId + * @param int $folderId * @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) { @@ -81,7 +85,8 @@ 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 // prevent already exists exceptions @@ -105,7 +110,8 @@ 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){ @@ -120,13 +126,16 @@ class FolderController extends Controller { * @NoAdminRequired * * @param string $folderName - * @param int $folderId + * @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, - $this->userId); + $folder = $this->folderService->rename( + $folderId, $folderName, + $this->userId + ); return ['folders' => [$folder]]; @@ -147,7 +156,8 @@ class FolderController extends Controller { * @param int $highestItemId * @return array */ - public function read($folderId, $highestItemId) { + public function read($folderId, $highestItemId) + { $this->itemService->readFolder( $folderId, $highestItemId, $this->userId ); @@ -162,7 +172,8 @@ class FolderController extends Controller { * @param int $folderId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function restore($folderId) { + public function restore($folderId) + { try { $this->folderService->unmarkDeleted($folderId, $this->userId); } catch (ServiceNotFoundException $ex){ diff --git a/lib/Controller/ItemApiController.php b/lib/Controller/ItemApiController.php index b99c773a0..ae523a5f1 100644 --- a/lib/Controller/ItemApiController.php +++ b/lib/Controller/ItemApiController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -19,7 +19,8 @@ use \OCP\AppFramework\Http; use \OCA\News\Service\ItemService; use \OCA\News\Service\ServiceNotFoundException; -class ItemApiController extends ApiController { +class ItemApiController extends ApiController +{ use JSONHttpError; @@ -27,11 +28,12 @@ class ItemApiController extends ApiController { private $userId; private $serializer; - public function __construct($AppName, - IRequest $request, - ItemService $itemService, - $UserId){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + ItemService $itemService, + $UserId + ) { + parent::__construct($appName, $request); $this->itemService = $itemService; $this->userId = $UserId; $this->serializer = new EntityApiSerializer('items'); @@ -43,16 +45,17 @@ class ItemApiController extends ApiController { * @NoCSRFRequired * @CORS * - * @param int $type - * @param int $id + * @param int $type + * @param int $id * @param bool $getRead - * @param int $batchSize - * @param int $offset + * @param int $batchSize + * @param int $offset * @param bool $oldestFirst * @return array|mixed */ public function index($type=3, $id=0, $getRead=true, $batchSize=-1, - $offset=0, $oldestFirst=false) { + $offset=0, $oldestFirst=false + ) { return $this->serializer->serialize( $this->itemService->findAll( $id, $type, $batchSize, $offset, $getRead, $oldestFirst, @@ -72,7 +75,8 @@ class ItemApiController extends ApiController { * @param int $lastModified * @return array|mixed */ - public function updated($type=3, $id=0, $lastModified=0) { + public function updated($type=3, $id=0, $lastModified=0) + { // needs to be turned into a millisecond timestamp to work properly if (strlen((string) $lastModified) <= 10) { $paddedLastModified = $lastModified . '000000'; @@ -80,13 +84,16 @@ class ItemApiController extends ApiController { $paddedLastModified = $lastModified; } return $this->serializer->serialize( - $this->itemService->findAllNew($id, $type, $paddedLastModified, - true, $this->userId) + $this->itemService->findAllNew( + $id, $type, $paddedLastModified, + true, $this->userId + ) ); } - private function setRead($isRead, $itemId) { + private function setRead($isRead, $itemId) + { try { $this->itemService->read($itemId, $isRead, $this->userId); } catch(ServiceNotFoundException $ex){ @@ -105,7 +112,8 @@ class ItemApiController extends ApiController { * @param int $itemId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function read($itemId) { + public function read($itemId) + { return $this->setRead(true, $itemId); } @@ -118,12 +126,14 @@ class ItemApiController extends ApiController { * @param int $itemId * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function unread($itemId) { + public function unread($itemId) + { return $this->setRead(false, $itemId); } - private function setStarred($isStarred, $feedId, $guidHash) { + private function setStarred($isStarred, $feedId, $guidHash) + { try { $this->itemService->star( $feedId, $guidHash, $isStarred, $this->userId @@ -141,11 +151,12 @@ class ItemApiController extends ApiController { * @NoCSRFRequired * @CORS * - * @param int $feedId + * @param int $feedId * @param string $guidHash * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function star($feedId, $guidHash) { + public function star($feedId, $guidHash) + { return $this->setStarred(true, $feedId, $guidHash); } @@ -155,11 +166,12 @@ class ItemApiController extends ApiController { * @NoCSRFRequired * @CORS * - * @param int $feedId + * @param int $feedId * @param string $guidHash * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function unstar($feedId, $guidHash) { + public function unstar($feedId, $guidHash) + { return $this->setStarred(false, $feedId, $guidHash); } @@ -171,12 +183,14 @@ class ItemApiController extends ApiController { * * @param int $newestItemId */ - public function readAll($newestItemId) { + public function readAll($newestItemId) + { $this->itemService->readAll($newestItemId, $this->userId); } - private function setMultipleRead($isRead, $items) { + private function setMultipleRead($isRead, $items) + { foreach($items as $id) { try { $this->itemService->read($id, $isRead, $this->userId); @@ -194,7 +208,8 @@ class ItemApiController extends ApiController { * * @param int[] item ids */ - public function readMultiple($items) { + public function readMultiple($items) + { $this->setMultipleRead(true, $items); } @@ -206,16 +221,20 @@ class ItemApiController extends ApiController { * * @param int[] item ids */ - public function unreadMultiple($items) { + public function unreadMultiple($items) + { $this->setMultipleRead(false, $items); } - private function setMultipleStarred($isStarred, $items) { + private function setMultipleStarred($isStarred, $items) + { foreach($items as $item) { try { - $this->itemService->star($item['feedId'], $item['guidHash'], - $isStarred, $this->userId); + $this->itemService->star( + $item['feedId'], $item['guidHash'], + $isStarred, $this->userId + ); } catch(ServiceNotFoundException $ex) { continue; } @@ -230,7 +249,8 @@ class ItemApiController extends ApiController { * * @param int[] item ids */ - public function starMultiple($items) { + public function starMultiple($items) + { $this->setMultipleStarred(true, $items); } @@ -242,7 +262,8 @@ class ItemApiController extends ApiController { * * @param int[] item ids */ - public function unstarMultiple($items) { + public function unstarMultiple($items) + { $this->setMultipleStarred(false, $items); } diff --git a/lib/Controller/ItemController.php b/lib/Controller/ItemController.php index 332b9933f..9c0801b1d 100644 --- a/lib/Controller/ItemController.php +++ b/lib/Controller/ItemController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -24,7 +24,8 @@ use \OCA\News\Service\ItemService; use \OCA\News\Service\FeedService; -class ItemController extends Controller { +class ItemController extends Controller +{ use JSONHttpError; @@ -33,13 +34,14 @@ class ItemController extends Controller { private $userId; private $settings; - public function __construct($AppName, - IRequest $request, - FeedService $feedService, - ItemService $itemService, - IConfig $settings, - $UserId){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + FeedService $feedService, + ItemService $itemService, + IConfig $settings, + $UserId + ) { + parent::__construct($appName, $request); $this->itemService = $itemService; $this->feedService = $feedService; $this->userId = $UserId; @@ -50,23 +52,24 @@ class ItemController extends Controller { /** * @NoAdminRequired * - * @param int $type - * @param int $id - * @param int $limit - * @param int $offset - * @param bool $showAll - * @param bool $oldestFirst + * @param int $type + * @param int $id + * @param int $limit + * @param int $offset + * @param bool $showAll + * @param bool $oldestFirst * @param string $search * @return array */ public function index($type=3, $id=0, $limit=50, $offset=0, $showAll=null, - $oldestFirst=null, $search='') { + $oldestFirst=null, $search='' + ) { // in case this is called directly and not from the website use the // internal state if ($showAll === null) { $showAll = $this->settings->getUserValue( - $this->userId, $this->appName,'showAll' + $this->userId, $this->appName, 'showAll' ) === '1'; } @@ -76,10 +79,14 @@ class ItemController extends Controller { ) === '1'; } - $this->settings->setUserValue($this->userId, $this->appName, - 'lastViewedFeedId', $id); - $this->settings->setUserValue($this->userId, $this->appName, - 'lastViewedFeedType', $type); + $this->settings->setUserValue( + $this->userId, $this->appName, + 'lastViewedFeedId', $id + ); + $this->settings->setUserValue( + $this->userId, $this->appName, + 'lastViewedFeedType', $type + ); $params = []; @@ -110,9 +117,10 @@ class ItemController extends Controller { $this->userId, $search ); - // this gets thrown if there are no items - // in that case just return an empty array - } catch(ServiceException $ex) {} + // this gets thrown if there are no items + // in that case just return an empty array + } catch(ServiceException $ex) { + } return $params; } @@ -126,9 +134,12 @@ class ItemController extends Controller { * @param int $lastModified * @return array */ - public function newItems($type, $id, $lastModified=0) { - $showAll = $this->settings->getUserValue($this->userId, $this->appName, - 'showAll') === '1'; + public function newItems($type, $id, $lastModified=0) + { + $showAll = $this->settings->getUserValue( + $this->userId, $this->appName, + 'showAll' + ) === '1'; $params = []; @@ -138,12 +149,15 @@ class ItemController extends Controller { $params['feeds'] = $this->feedService->findAll($this->userId); $params['starred'] = $this->itemService->starredCount($this->userId); - $params['items'] = $this->itemService->findAllNew($id, $type, - $lastModified, $showAll, $this->userId); + $params['items'] = $this->itemService->findAllNew( + $id, $type, + $lastModified, $showAll, $this->userId + ); - // this gets thrown if there are no items - // in that case just return an empty array - } catch(ServiceException $ex) {} + // this gets thrown if there are no items + // in that case just return an empty array + } catch(ServiceException $ex) { + } return $params; } @@ -152,15 +166,18 @@ class ItemController extends Controller { /** * @NoAdminRequired * - * @param int $feedId + * @param int $feedId * @param string $guidHash - * @param bool $isStarred + * @param bool $isStarred * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function star($feedId, $guidHash, $isStarred){ + public function star($feedId, $guidHash, $isStarred) + { try { - $this->itemService->star($feedId, $guidHash, $isStarred, - $this->userId); + $this->itemService->star( + $feedId, $guidHash, $isStarred, + $this->userId + ); } catch(ServiceException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); } @@ -172,11 +189,12 @@ class ItemController extends Controller { /** * @NoAdminRequired * - * @param int $itemId + * @param int $itemId * @param bool $isRead * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function read($itemId, $isRead=true){ + public function read($itemId, $isRead=true) + { try { $this->itemService->read($itemId, $isRead, $this->userId); } catch(ServiceException $ex) { @@ -193,7 +211,8 @@ class ItemController extends Controller { * @param int $highestItemId * @return array */ - public function readAll($highestItemId){ + public function readAll($highestItemId) + { $this->itemService->readAll($highestItemId, $this->userId); return ['feeds' => $this->feedService->findAll($this->userId)]; } @@ -204,7 +223,8 @@ class ItemController extends Controller { * * @param int[] item ids */ - public function readMultiple($itemIds) { + public function readMultiple($itemIds) + { foreach($itemIds as $id) { try { $this->itemService->read($id, true, $this->userId); diff --git a/lib/Controller/JSONHttpError.php b/lib/Controller/JSONHttpError.php index 03b9c684a..b79b77567 100644 --- a/lib/Controller/JSONHttpError.php +++ b/lib/Controller/JSONHttpError.php @@ -5,7 +5,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Bernhard Posselt + * @author Bernhard Posselt * @copyright Bernhard Posselt 2014 */ @@ -14,16 +14,18 @@ namespace OCA\News\Controller; use \OCP\AppFramework\Http\JSONResponse; -trait JSONHttpError { +trait JSONHttpError +{ /** * @param \Exception $exception the message that is returned taken from the - * exception - * @param int $code the http error code + * exception + * @param int $code the http error code * @return \OCP\AppFramework\Http\JSONResponse */ - public function error(\Exception $exception, $code) { + public function error(\Exception $exception, $code) + { return new JSONResponse(['message' => $exception->getMessage()], $code); } diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 22f79952a..3d3bab76b 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -29,7 +29,8 @@ use OCA\News\Explore\RecommendedSites; use OCA\News\Explore\RecommendedSiteNotFoundException; use OCA\News\Db\FeedType; -class PageController extends Controller { +class PageController extends Controller +{ private $settings; private $l10n; @@ -41,16 +42,17 @@ class PageController extends Controller { use JSONHttpError; - public function __construct($AppName, - IRequest $request, - IConfig $settings, - IURLGenerator $urlGenerator, - Config $config, - IL10N $l10n, - RecommendedSites $recommendedSites, - StatusService $statusService, - $UserId){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + IConfig $settings, + IURLGenerator $urlGenerator, + Config $config, + IL10N $l10n, + RecommendedSites $recommendedSites, + StatusService $statusService, + $UserId + ) { + parent::__construct($appName, $request); $this->settings = $settings; $this->urlGenerator = $urlGenerator; $this->l10n = $l10n; @@ -65,12 +67,15 @@ class PageController extends Controller { * @NoAdminRequired * @NoCSRFRequired */ - public function index() { + public function index() + { $status = $this->statusService->getStatus(); - $response = new TemplateResponse($this->appName, 'index', [ + $response = new TemplateResponse( + $this->appName, 'index', [ 'warnings' => $status['warnings'], 'url_generator' => $this->urlGenerator - ]); + ] + ); $csp = new ContentSecurityPolicy(); $csp->addAllowedImageDomain('*') @@ -91,7 +96,8 @@ class PageController extends Controller { /** * @NoAdminRequired */ - public function settings() { + public function settings() + { $settings = [ 'showAll', 'compact', @@ -132,7 +138,8 @@ class PageController extends Controller { * @param bool $oldestFirst */ public function updateSettings($showAll, $compact, $preventReadOnScroll, - $oldestFirst, $compactExpand) { + $oldestFirst, $compactExpand + ) { $settings = ['showAll', 'compact', 'preventReadOnScroll', @@ -146,8 +153,10 @@ class PageController extends Controller { } else { $value = '0'; } - $this->settings->setUserValue($this->userId, $this->appName, - $setting, $value); + $this->settings->setUserValue( + $this->userId, $this->appName, + $setting, $value + ); } } @@ -156,11 +165,16 @@ class PageController extends Controller { * * @param string $lang */ - public function explore($lang) { - $this->settings->setUserValue($this->userId, $this->appName, - 'lastViewedFeedId', 0); - $this->settings->setUserValue($this->userId, $this->appName, - 'lastViewedFeedType', FeedType::EXPLORE); + public function explore($lang) + { + $this->settings->setUserValue( + $this->userId, $this->appName, + 'lastViewedFeedId', 0 + ); + $this->settings->setUserValue( + $this->userId, $this->appName, + 'lastViewedFeedType', FeedType::EXPLORE + ); try { return $this->recommendedSites->forLanguage($lang); diff --git a/lib/Controller/UserApiController.php b/lib/Controller/UserApiController.php index 66b013f53..cb3b8b419 100644 --- a/lib/Controller/UserApiController.php +++ b/lib/Controller/UserApiController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -19,16 +19,18 @@ use \OCP\IURLGenerator; use \OCP\Files\IRootFolder; use \OCP\AppFramework\Http; -class UserApiController extends ApiController { +class UserApiController extends ApiController +{ private $userSession; private $rootFolder; - public function __construct($AppName, - IRequest $request, - IUserSession $userSession, - IRootFolder $rootFolder){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + IUserSession $userSession, + IRootFolder $rootFolder + ) { + parent::__construct($appName, $request); $this->userSession = $userSession; $this->rootFolder = $rootFolder; } @@ -38,7 +40,8 @@ class UserApiController extends ApiController { * @NoCSRFRequired * @CORS */ - public function index() { + public function index() + { $user = $this->userSession->getUser(); // find the avatar diff --git a/lib/Controller/UtilityApiController.php b/lib/Controller/UtilityApiController.php index 0356f25be..7fc6403c8 100644 --- a/lib/Controller/UtilityApiController.php +++ b/lib/Controller/UtilityApiController.php @@ -5,10 +5,10 @@ * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * - * @author Alessandro Cosentino - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 + * @author Alessandro Cosentino + * @author Bernhard Posselt + * @copyright 2012 Alessandro Cosentino + * @copyright 2012-2014 Bernhard Posselt */ namespace OCA\News\Controller; @@ -21,18 +21,20 @@ use \OCA\News\Utility\Updater; use \OCA\News\Service\StatusService; -class UtilityApiController extends ApiController { +class UtilityApiController extends ApiController +{ private $updater; private $settings; private $statusService; - public function __construct($AppName, - IRequest $request, - Updater $updater, - IConfig $settings, - StatusService $statusService){ - parent::__construct($AppName, $request); + public function __construct($appName, + IRequest $request, + Updater $updater, + IConfig $settings, + StatusService $statusService + ) { + parent::__construct($appName, $request); $this->updater = $updater; $this->settings = $settings; $this->statusService = $statusService; @@ -44,9 +46,12 @@ class UtilityApiController extends ApiController { * @NoCSRFRequired * @CORS */ - public function version() { - $version = $this->settings->getAppValue($this->appName, - 'installed_version'); + public function version() + { + $version = $this->settings->getAppValue( + $this->appName, + 'installed_version' + ); return ['version' => $version]; } @@ -55,7 +60,8 @@ class UtilityApiController extends ApiController { * @NoCSRFRequired * @CORS */ - public function beforeUpdate() { + public function beforeUpdate() + { $this->updater->beforeUpdate(); } @@ -64,7 +70,8 @@ class UtilityApiController extends ApiController { * @NoCSRFRequired * @CORS */ - public function afterUpdate() { + public function afterUpdate() + { $this->updater->afterUpdate(); } @@ -74,7 +81,8 @@ class UtilityApiController extends ApiController { * @NoCSRFRequired * @NoAdminRequired */ - public function status() { + public function status() + { return $this->statusService->getStatus(); } -- cgit v1.2.3