Implemented StackApiController Get Function.
Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
committed by
Julius Härtl
parent
dd1d4246fe
commit
cfd9ab98c6
@@ -86,6 +86,7 @@ return [
|
||||
['name' => 'board_api#undo_delete', 'url' => '/api/v1.0/boards/{boardId}/undo_delete', 'verb' => 'POST'],
|
||||
|
||||
['name' => 'stack_api#index', 'url' => '/api/v1.0/boards/{boardId}/stacks', 'verb' => 'GET'],
|
||||
['name' => 'stack_api#index', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}', 'verb' => 'GET'],
|
||||
['name' => 'stack_api#create', 'url' => '/api/v1.0/boards/{boardId}/stacks', 'verb' => 'POST'],
|
||||
['name' => 'stack_api#update', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}', 'verb' => 'PUT'],
|
||||
['name' => 'stack_api#delete', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}', 'verb' => 'DELETE'],
|
||||
|
||||
@@ -66,7 +66,7 @@ class StackApiController extends ApiController {
|
||||
* Return all of the stacks in the specified board.
|
||||
*/
|
||||
public function index() {
|
||||
$boardError = $this->apiHelper->entityHasError( $this->request->params['boardId'], 'board', $this->boardService );
|
||||
$boardError = $this->apiHelper->entityHasError($this->request->params['boardId'], 'board', $this->boardService);
|
||||
|
||||
if ($boardError) {
|
||||
return new DataResponse($boardError['message'], $boardError['status']);
|
||||
@@ -81,8 +81,29 @@ class StackApiController extends ApiController {
|
||||
return new DataResponse($stacks, HTTP::STATUS_OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @CORS
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* Return all of the stacks in the specified board.
|
||||
*/
|
||||
public function get() {
|
||||
$boardError = $this->apiHelper->entityHasError($this->request->params['boardId'], 'board', $this->boardService);
|
||||
|
||||
if ($boardError) {
|
||||
return new DataResponse($boardError['message'], $boardError['status']);
|
||||
}
|
||||
|
||||
$stack = $this->service->find($this->request->params['stackId']);
|
||||
|
||||
if ($stack == false || $stack == null) {
|
||||
return new DataResponse("Stack not found", HTTP::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return new DataResponse($stack, HTTP::STATUS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @CORS
|
||||
|
||||
@@ -89,9 +89,19 @@ class StackService {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Write this function so we can look up one stack id.
|
||||
public function find($stackId) {
|
||||
throw new \Exception('Not yet implemented');
|
||||
$stack = $this->stackMapper->find($stackId);
|
||||
$cards = $this->cardMapper->findAll($stackId);
|
||||
foreach ($cards as $cardIndex => $card) {
|
||||
$assignedUsers = $this->assignedUsersMapper->find($card->getId());
|
||||
$card->setAssignedUsers($assignedUsers);
|
||||
if (array_key_exists($card->id, $labels)) {
|
||||
$cards[$cardIndex]->setLabels($labels[$card->id]);
|
||||
}
|
||||
$card->setAttachmentCount($this->attachmentService->count($card->getId()));
|
||||
}
|
||||
$stack->setCards($cards);
|
||||
return $stack;
|
||||
}
|
||||
|
||||
public function findAll($boardId) {
|
||||
|
||||
Reference in New Issue
Block a user