Extract getBoardPererequisites() so it can be re-used.

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Steven R. Baker
2018-02-12 12:11:39 +01:00
committed by Julius Härtl
parent 41cf623bb8
commit 1ffa3211ba
3 changed files with 13 additions and 25 deletions

View File

@@ -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];
}
}

View File

@@ -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();
}
/**

View File

@@ -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;