| @@ 75-98 (lines=24) @@ | ||
| 72 | * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
| 73 | * @throws BadRequestException |
|
| 74 | */ |
|
| 75 | public function create($title, $color, $boardId) { |
|
| 76 | ||
| 77 | if ($title === false || $title === null) { |
|
| 78 | throw new BadRequestException('title must be provided'); |
|
| 79 | } |
|
| 80 | ||
| 81 | if ($color === false || $color === null) { |
|
| 82 | throw new BadRequestException('color must be provided'); |
|
| 83 | } |
|
| 84 | ||
| 85 | if (is_numeric($boardId) === false) { |
|
| 86 | throw new BadRequestException('board id must be a number'); |
|
| 87 | } |
|
| 88 | ||
| 89 | $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); |
|
| 90 | if ($this->boardService->isArchived(null, $boardId)) { |
|
| 91 | throw new StatusException('Operation not allowed. This board is archived.'); |
|
| 92 | } |
|
| 93 | $label = new Label(); |
|
| 94 | $label->setTitle($title); |
|
| 95 | $label->setColor($color); |
|
| 96 | $label->setBoardId($boardId); |
|
| 97 | return $this->labelMapper->insert($label); |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * @param $id |
|
| @@ 176-200 (lines=25) @@ | ||
| 173 | * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
| 174 | * @throws BadRequestException |
|
| 175 | */ |
|
| 176 | public function create($title, $boardId, $order) { |
|
| 177 | ||
| 178 | if ($title === false || $title === null) { |
|
| 179 | throw new BadRequestException('title must be provided'); |
|
| 180 | } |
|
| 181 | ||
| 182 | if (is_numeric($order) === false) { |
|
| 183 | throw new BadRequestException('order must be a number'); |
|
| 184 | } |
|
| 185 | ||
| 186 | if (is_numeric($boardId) === false) { |
|
| 187 | throw new BadRequestException('board id must be a number'); |
|
| 188 | } |
|
| 189 | ||
| 190 | $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); |
|
| 191 | if ($this->boardService->isArchived(null, $boardId)) { |
|
| 192 | throw new StatusException('Operation not allowed. This board is archived.'); |
|
| 193 | } |
|
| 194 | $stack = new Stack(); |
|
| 195 | $stack->setTitle($title); |
|
| 196 | $stack->setBoardId($boardId); |
|
| 197 | $stack->setOrder($order); |
|
| 198 | return $this->stackMapper->insert($stack); |
|
| 199 | ||
| 200 | } |
|
| 201 | ||
| 202 | /** |
|
| 203 | * @param $id |
|