private function setColumns(AgileDashboard_Kanban $kanban, AgileDashboard_KanbanColumnFactory $column_factory, $user_can_add_in_place, PFUser $user) { $columns = $column_factory->getAllKanbanColumnsForAKanban($kanban, $user); foreach ($columns as $column) { $column_representation = new KanbanColumnRepresentation(); $column_representation->build($column, $user_can_add_in_place); $this->columns[] = $column_representation; } }
/** * Add a new column * * Create a new kanban column. Will add another open value to the field corresponding to * the 'Status' semantic. An error will be thrown if the semantic 'Status' is not bound to * static values. * * @url POST {id}/columns * * @param string $id Id of the Kanban * @param KanbanColumnPOSTRepresentation $column The created kanban column {@from body} {@type Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnPOSTRepresentation} * * @throws 400 * @throws 401 * @throws 403 * @throws 404 * * @status 201 * * @return Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnRepresentation */ protected function postColumns($id, KanbanColumnPOSTRepresentation $column) { $current_user = $this->getCurrentUser(); $kanban_id = $id; $kanban = $this->getKanban($current_user, $kanban_id); $column_label = $column->label; try { $new_column_id = $this->kanban_column_manager->createColumn($current_user, $kanban, $column_label); } catch (AgileDashboard_UserNotAdminException $exception) { throw new RestException(401, $exception->getMessage()); } catch (Kanban_SemanticStatusNotDefinedException $exception) { throw new RestException(404, $exception->getMessage()); } catch (Kanban_SemanticStatusNotBoundToStaticValuesException $exception) { throw new RestException(400, $exception->getMessage()); } catch (Kanban_SemanticStatusBasedOnASharedFieldException $exception) { throw new RestException(400, $exception->getMessage()); } $this->form_element_factory->clearCaches(); $new_column = $this->kanban_column_factory->getColumnForAKanban($kanban, $new_column_id, $current_user); try { $this->kanban_actions_checker->checkUserCanAddInPlace($current_user, $kanban); $add_in_place = true; } catch (Exception $exception) { $add_in_place = false; } try { $this->kanban_actions_checker->checkUserCanDeleteColumn($current_user, $kanban, $new_column); $user_can_remove_column = true; } catch (Exception $exception) { $user_can_remove_column = false; } try { $this->kanban_actions_checker->checkUserCanEditColumnLabel($current_user, $kanban); $user_can_edit_label = true; } catch (Exception $exception) { $user_can_edit_label = false; } $column_representation = new KanbanColumnRepresentation(); $column_representation->build($new_column, $add_in_place, $user_can_remove_column, $user_can_edit_label); return $column_representation; }
/** * Add a new column * * Create a new kanban column. Will add another open value to the field corresponding to * the 'Status' semantic. An error will be thrown if the semantic 'Status' is not bound to * static values. * * @url POST {id}/columns * * @param string $id Id of the Kanban * @param KanbanColumnPOSTRepresentation $column The created kanban column {@from body} {@type Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnPOSTRepresentation} * * @throws 400 * @throws 401 * @throws 403 * @throws 404 * * @status 201 * * @return Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnRepresentation */ protected function postColumns($id, KanbanColumnPOSTRepresentation $column) { $current_user = $this->getCurrentUser(); $kanban_id = $id; $kanban = $this->getKanban($current_user, $kanban_id); $column_label = $column->label; try { $new_column_id = $this->kanban_column_manager->createColumn($current_user, $kanban, $column_label); } catch (AgileDashboard_UserNotAdminException $exception) { throw new RestException(401, $exception->getMessage()); } catch (Kanban_SemanticStatus_Not_DefinedException $exception) { throw new RestException(404, $exception->getMessage()); } catch (Kanban_SemanticStatus_Not_Bound_To_Static_ValuesException $exception) { throw new RestException(400, $exception->getMessage()); } $this->form_element_factory->clearCaches(); $new_column = $this->kanban_column_factory->getColumnForAKanban($kanban, $new_column_id, $current_user); $add_in_place = $this->add_in_place_checker->canUserAddInPlace($current_user, $kanban); $column_representation = new KanbanColumnRepresentation(); $column_representation->build($new_column, $add_in_place); return $column_representation; }
private function setColumns(AgileDashboard_Kanban $kanban, AgileDashboard_KanbanColumnFactory $column_factory, AgileDashboard_KanbanActionsChecker $kanban_actions_checker, $user_can_add_in_place, PFUser $user) { $columns = $column_factory->getAllKanbanColumnsForAKanban($kanban, $user); foreach ($columns as $column) { try { $kanban_actions_checker->checkUserCanDeleteColumn($user, $kanban, $column); $user_can_remove_column = true; } catch (Exception $exception) { $user_can_remove_column = false; } try { $kanban_actions_checker->checkUserCanEditColumnLabel($user, $kanban); $user_can_edit_label = true; } catch (Exception $exception) { $user_can_edit_label = false; } $column_representation = new KanbanColumnRepresentation(); $column_representation->build($column, $user_can_add_in_place, $user_can_remove_column, $user_can_edit_label); $this->columns[] = $column_representation; } }