| @@ 8-30 (lines=23) @@ | ||
| 5 | /** |
|
| 6 | * Create Task Controller. |
|
| 7 | */ |
|
| 8 | class CreateTask extends BaseTaskController |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Create a task. |
|
| 12 | * |
|
| 13 | * @param Request $request |
|
| 14 | * @param Response $response |
|
| 15 | * @param array $args |
|
| 16 | * @return array |
|
| 17 | */ |
|
| 18 | public function createTask($request, $response, $args) |
|
| 19 | { |
|
| 20 | try { |
|
| 21 | $this->setParams($request, $response, $args); |
|
| 22 | $input = $this->request->getParsedBody(); |
|
| 23 | $result = $this->getTaskService()->createTask($input); |
|
| 24 | ||
| 25 | return $this->jsonResponse('success', $result, 201); |
|
| 26 | } catch (\Exception $ex) { |
|
| 27 | return $this->jsonResponse('error', $ex->getMessage(), $ex->getCode()); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | } |
|
| 31 | ||
| @@ 8-29 (lines=22) @@ | ||
| 5 | /** |
|
| 6 | * Delete Task Controller. |
|
| 7 | */ |
|
| 8 | class DeleteTask extends BaseTaskController |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Delete a task. |
|
| 12 | * |
|
| 13 | * @param Request $request |
|
| 14 | * @param Response $response |
|
| 15 | * @param array $args |
|
| 16 | * @return array |
|
| 17 | */ |
|
| 18 | public function deleteTask($request, $response, $args) |
|
| 19 | { |
|
| 20 | try { |
|
| 21 | $this->setParams($request, $response, $args); |
|
| 22 | $result = $this->getTaskService()->deleteTask($this->args['id']); |
|
| 23 | ||
| 24 | return $this->jsonResponse('success', $result, 200); |
|
| 25 | } catch (\Exception $ex) { |
|
| 26 | return $this->jsonResponse('error', $ex->getMessage(), $ex->getCode()); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| @@ 8-29 (lines=22) @@ | ||
| 5 | /** |
|
| 6 | * Get One Task Controller. |
|
| 7 | */ |
|
| 8 | class GetOneTask extends BaseTaskController |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Get one task by id. |
|
| 12 | * |
|
| 13 | * @param Request $request |
|
| 14 | * @param Response $response |
|
| 15 | * @param array $args |
|
| 16 | * @return array |
|
| 17 | */ |
|
| 18 | public function getTask($request, $response, $args) |
|
| 19 | { |
|
| 20 | try { |
|
| 21 | $this->setParams($request, $response, $args); |
|
| 22 | $result = $this->getTaskService()->getTask($this->args['id']); |
|
| 23 | ||
| 24 | return $this->jsonResponse('success', $result, 200); |
|
| 25 | } catch (\Exception $ex) { |
|
| 26 | return $this->jsonResponse('error', $ex->getMessage(), $ex->getCode()); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| @@ 8-29 (lines=22) @@ | ||
| 5 | /** |
|
| 6 | * Search Tasks Controller. |
|
| 7 | */ |
|
| 8 | class SearchTasks extends BaseTaskController |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Search tasks by name. |
|
| 12 | * |
|
| 13 | * @param Request $request |
|
| 14 | * @param Response $response |
|
| 15 | * @param array $args |
|
| 16 | * @return array |
|
| 17 | */ |
|
| 18 | public function searchTasks($request, $response, $args) |
|
| 19 | { |
|
| 20 | try { |
|
| 21 | $this->setParams($request, $response, $args); |
|
| 22 | $result = $this->getTaskService()->searchTasks($this->args['query']); |
|
| 23 | ||
| 24 | return $this->jsonResponse('success', $result, 200); |
|
| 25 | } catch (\Exception $ex) { |
|
| 26 | return $this->jsonResponse('error', $ex->getMessage(), $ex->getCode()); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| @@ 8-30 (lines=23) @@ | ||
| 5 | /** |
|
| 6 | * Update Task Controller. |
|
| 7 | */ |
|
| 8 | class UpdateTask extends BaseTaskController |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * Update a task. |
|
| 12 | * |
|
| 13 | * @param Request $request |
|
| 14 | * @param Response $response |
|
| 15 | * @param array $args |
|
| 16 | * @return array |
|
| 17 | */ |
|
| 18 | public function updateTask($request, $response, $args) |
|
| 19 | { |
|
| 20 | try { |
|
| 21 | $this->setParams($request, $response, $args); |
|
| 22 | $input = $this->request->getParsedBody(); |
|
| 23 | $result = $this->getTaskService()->updateTask($input, $this->args['id']); |
|
| 24 | ||
| 25 | return $this->jsonResponse('success', $result, 200); |
|
| 26 | } catch (\Exception $ex) { |
|
| 27 | return $this->jsonResponse('error', $ex->getMessage(), $ex->getCode()); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | } |
|
| 31 | ||