From 1ffa3211bae5ea6af576a354d3a8cb1cc68c0820 Mon Sep 17 00:00:00 2001 From: "Steven R. Baker" Date: Mon, 12 Feb 2018 12:11:39 +0100 Subject: [PATCH] Extract getBoardPererequisites() so it can be re-used. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Controller/BoardApiController.php | 12 ++---------- lib/Controller/BoardController.php | 16 +--------------- lib/Service/BoardService.php | 10 ++++++++++ 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/lib/Controller/BoardApiController.php b/lib/Controller/BoardApiController.php index 088a62d73..5222068d7 100644 --- a/lib/Controller/BoardApiController.php +++ b/lib/Controller/BoardApiController.php @@ -55,6 +55,7 @@ class BoardApiController extends ApiController { $this->userId = $userId; $this->userManager = $userManager; $this->groupManager = $groupManager; + $this->userInfo = $this->service->getBoardPrerequisites(); } /** @@ -65,7 +66,7 @@ class BoardApiController extends ApiController { * Return all of the boards that the current user has access to. */ public function index() { - $boards = $this->service->findAll($this->getUserInfo()); + $boards = $this->service->findAll($this->userInfo); return new DataResponse($boards); } @@ -132,13 +133,4 @@ class BoardApiController extends ApiController { return new DataResponse($board); } - // 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]; - } - } diff --git a/lib/Controller/BoardController.php b/lib/Controller/BoardController.php index 0ecd044b1..d447f849e 100644 --- a/lib/Controller/BoardController.php +++ b/lib/Controller/BoardController.php @@ -47,21 +47,7 @@ class BoardController extends ApiController { $this->groupManager = $groupManager; $this->boardService = $boardService; $this->permissionService = $permissionService; - $this->userInfo = $this->getBoardPrerequisites(); - } - - /** - * TODO: move to boardservice - * @return array - */ - private function getBoardPrerequisites() { - $groups = $this->groupManager->getUserGroupIds( - $this->userManager->get($this->userId) - ); - return [ - 'user' => $this->userId, - 'groups' => $groups - ]; + $this->userInfo = $this->boardSerivce->getBoardPrerequisites(); } /** diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index ab6baf225..e9140d09a 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -112,6 +112,16 @@ class BoardService { return $board; } + public function getBoardPrerequisites() { + $groups = $this->groupManager->getUserGroupIds( + $this->userManager->get($this->userId) + ); + return [ + 'user' => $this->userId, + 'groups' => $groups + ]; + } + public function isArchived($mapper, $id) { try { $boardId = $id;