Extract getBoardPererequisites() so it can be re-used.
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
41cf623bb8
commit
1ffa3211ba
@@ -55,6 +55,7 @@ class BoardApiController extends ApiController {
|
|||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
$this->groupManager = $groupManager;
|
$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.
|
* Return all of the boards that the current user has access to.
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
$boards = $this->service->findAll($this->getUserInfo());
|
$boards = $this->service->findAll($this->userInfo);
|
||||||
|
|
||||||
return new DataResponse($boards);
|
return new DataResponse($boards);
|
||||||
}
|
}
|
||||||
@@ -132,13 +133,4 @@ class BoardApiController extends ApiController {
|
|||||||
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->userManager->get($this->userId)
|
|
||||||
);
|
|
||||||
return ['user' => $this->userId,
|
|
||||||
'groups' => $groups];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,21 +47,7 @@ class BoardController extends ApiController {
|
|||||||
$this->groupManager = $groupManager;
|
$this->groupManager = $groupManager;
|
||||||
$this->boardService = $boardService;
|
$this->boardService = $boardService;
|
||||||
$this->permissionService = $permissionService;
|
$this->permissionService = $permissionService;
|
||||||
$this->userInfo = $this->getBoardPrerequisites();
|
$this->userInfo = $this->boardSerivce->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
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -112,6 +112,16 @@ class BoardService {
|
|||||||
return $board;
|
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) {
|
public function isArchived($mapper, $id) {
|
||||||
try {
|
try {
|
||||||
$boardId = $id;
|
$boardId = $id;
|
||||||
|
|||||||
Reference in New Issue
Block a user