diff --git a/appinfo/routes.php b/appinfo/routes.php index 209227f6e..f54a04eda 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -76,18 +76,18 @@ return [ ['name' => 'label#update', 'url' => '/labels/{labelId}', 'verb' => 'PUT'], ['name' => 'label#delete', 'url' => '/labels/{labelId}', 'verb' => 'DELETE'], - // api - ['name' => 'board_api#index', 'url' => '/api/v1.0/boards', 'verb' => 'GET'], - ['name' => 'board_api#get', 'url' => '/api/v1.0/board/{id}', 'verb' => 'GET'], - ['name' => 'board_api#create', 'url' => '/api/v1.0/board', 'verb' => 'POST'], - ['name' => 'board_api#delete', 'url' => '/api/v1.0/board/{id}', 'verb' => 'DELETE'], - ['name' => 'board_api#undo_delete', 'url' => '/api/v1.0/board/{id}/undo_delete', 'verb' => 'POST'], + // api + ['name' => 'board_api#index', 'url' => '/api/v1.0/boards', 'verb' => 'GET'], + ['name' => 'board_api#get', 'url' => '/api/v1.0/board/{id}', 'verb' => 'GET'], + ['name' => 'board_api#create', 'url' => '/api/v1.0/board', 'verb' => 'POST'], + ['name' => 'board_api#delete', 'url' => '/api/v1.0/board/{id}', 'verb' => 'DELETE'], + ['name' => 'board_api#undo_delete', 'url' => '/api/v1.0/board/{id}/undo_delete', 'verb' => 'POST'], - ['name' => 'stack_api#index', 'url' => '/api/v1.0/board/{boardId}/stacks', 'verb' => 'GET'], - ['name' => 'stack_api#create', 'url' => '/api/v1.0/board/{boardId}/stack', 'verb' => 'POST'], - ['name' => 'stack_api#delete', 'url' => '/api/v1.0/board/{boardId}/stack/{id}', 'verb' => 'DELETE'], + ['name' => 'stack_api#index', 'url' => '/api/v1.0/board/{boardId}/stacks', 'verb' => 'GET'], + ['name' => 'stack_api#create', 'url' => '/api/v1.0/board/{boardId}/stack', 'verb' => 'POST'], + ['name' => 'stack_api#delete', 'url' => '/api/v1.0/board/{boardId}/stack/{id}', 'verb' => 'DELETE'], - ['name' => 'board_api#preflighted_cors', 'url' => '/api/v1.0/{path}', - 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']], + ['name' => 'board_api#preflighted_cors', 'url' => '/api/v1.0/{path}', + 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']], ] ]; diff --git a/lib/Controller/BoardApiController.php b/lib/Controller/BoardApiController.php index 814c942d3..22b7821ee 100644 --- a/lib/Controller/BoardApiController.php +++ b/lib/Controller/BoardApiController.php @@ -38,109 +38,109 @@ use OCA\Deck\Service\BoardService; */ class BoardApiController extends ApiController { - private $service; - private $userInfo; + private $service; + private $userInfo; - /** - * @param string $appName - * @param IRequest $request - * @param IUserManager $userManager - * @param IGroupManager $groupManager - * @param BoardService $service - * @param $userId - */ - public function __construct($appName, IRequest $request, IUserManager $userManager, IGroupManager $groupManager, BoardService $service, $userId) { - parent::__construct($appName, $request); - $this->service = $service; - $this->userId = $userId; - $this->userManager = $userManager; - $this->groupManager = $groupManager; - } + /** + * @param string $appName + * @param IRequest $request + * @param IUserManager $userManager + * @param IGroupManager $groupManager + * @param BoardService $service + * @param $userId + */ + public function __construct($appName, IRequest $request, IUserManager $userManager, IGroupManager $groupManager, BoardService $service, $userId) { + parent::__construct($appName, $request); + $this->service = $service; + $this->userId = $userId; + $this->userManager = $userManager; + $this->groupManager = $groupManager; + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * Return all of the boards that the current user has access to. - */ - public function index() { - $boards = $this->service->findAll($this->getUserInfo()); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * Return all of the boards that the current user has access to. + */ + public function index() { + $boards = $this->service->findAll($this->getUserInfo()); - return new DataResponse($boards); - } + return new DataResponse($boards); + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * @params $id - * - * Return the board specified by $id. - */ - public function get($id) { - $board = $this->service->find($id); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * @params $id + * + * Return the board specified by $id. + */ + public function get($id) { + $board = $this->service->find($id); - // FIXME: this should probably 404 if the board has been deleted + // FIXME: this should probably 404 if the board has been deleted - return new DataResponse($board); - } + return new DataResponse($board); + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * @params $title - * @params $color - * - * Create a board with the specified title and color. - */ - public function create($title, $color) { - $board = $this->service->create($title, $this->userId, $color); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * @params $title + * @params $color + * + * Create a board with the specified title and color. + */ + public function create($title, $color) { + $board = $this->service->create($title, $this->userId, $color); - return new DataResponse($board); - } + return new DataResponse($board); + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * @params $id - * - * Delete the board specified by $id. Return the board that was deleted. - */ - public function delete($id) { - $board = $this->service->delete($id); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * @params $id + * + * Delete the board specified by $id. Return the board that was deleted. + */ + public function delete($id) { + $board = $this->service->delete($id); - return new DataResponse($board); - } + return new DataResponse($board); + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * @params $id - * - * Undo the deletion of the board specified by $id. - */ - public function undoDelete($id) { - $board = $this->service->find($id); - $this->service->deleteUndo($id); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * @params $id + * + * Undo the deletion of the board specified by $id. + */ + public function undoDelete($id) { + $board = $this->service->find($id); + $this->service->deleteUndo($id); - return new DataResponse($board); - } + return new DataResponse($board); + } - // this is taken from BoardController, but it's not ideal - private function getUserInfo() { - $groups = $this->groupManager->getUserGroupIds( + // this is taken from BoardController, but it's not ideal + private function getUserInfo() { + $groups = $this->groupManager->getUserGroupIds( $this->userManager->get($this->userId) ); - return ['user' => $this->userId, - 'groups' => $groups]; - } + return ['user' => $this->userId, + 'groups' => $groups]; + } } diff --git a/lib/Controller/StackApiController.php b/lib/Controller/StackApiController.php index 159d571e2..9cae1a8af 100644 --- a/lib/Controller/StackApiController.php +++ b/lib/Controller/StackApiController.php @@ -36,62 +36,62 @@ use OCA\Deck\Service\StackService; */ class StackApiController extends ApiController { - private $service; - private $userInfo; + private $service; + private $userInfo; - /** - * @param string $appName - * @param IRequest $request - * @param StackService $service - */ - public function __construct($appName, IRequest $request, StackService $service) { - parent::__construct($appName, $request); - $this->service = $service; - } + /** + * @param string $appName + * @param IRequest $request + * @param StackService $service + */ + public function __construct($appName, IRequest $request, StackService $service) { + parent::__construct($appName, $request); + $this->service = $service; + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * Return all of the stacks in the specified board. - */ - public function index($boardId) { - $stacks = $this->service->findAll($boardId); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * Return all of the stacks in the specified board. + */ + public function index($boardId) { + $stacks = $this->service->findAll($boardId); - return new DataResponse($stacks); - } + return new DataResponse($stacks); + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * @params $title - * @params $order - * - * Create a stack with the specified title and order. - */ - public function create($boardId, $title, $order) { - // this throws a StatusException that needs to be caught and handled - $stack = $this->service->create($title, $boardId, $order); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * @params $title + * @params $order + * + * Create a stack with the specified title and order. + */ + public function create($boardId, $title, $order) { + // this throws a StatusException that needs to be caught and handled + $stack = $this->service->create($title, $boardId, $order); - return new DataResponse($stack); - } + return new DataResponse($stack); + } - /** - * @NoAdminRequired - * @CORS - * @NoCSRFRequired - * - * @params $id - * - * Delete the stack specified by $id. Return the board that was deleted. - */ - public function delete($boardId, $id) { - $stack = $this->service->delete($id); + /** + * @NoAdminRequired + * @CORS + * @NoCSRFRequired + * + * @params $id + * + * Delete the stack specified by $id. Return the board that was deleted. + */ + public function delete($boardId, $id) { + $stack = $this->service->delete($id); - return new DataResponse($stack); - } + return new DataResponse($stack); + } }