summaryrefslogtreecommitdiff
path: root/app/Api/Task.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Api/Task.php')
-rw-r--r--app/Api/Task.php26
1 files changed, 23 insertions, 3 deletions
diff --git a/app/Api/Task.php b/app/Api/Task.php
index e06c012b..ade49a6d 100644
--- a/app/Api/Task.php
+++ b/app/Api/Task.php
@@ -14,17 +14,17 @@ class Task extends Base
{
public function getTask($task_id)
{
- return $this->taskFinder->getById($task_id);
+ return $this->formatTask($this->taskFinder->getById($task_id));
}
public function getTaskByReference($project_id, $reference)
{
- return $this->taskFinder->getByReference($project_id, $reference);
+ return $this->formatTask($this->taskFinder->getByReference($project_id, $reference));
}
public function getAllTasks($project_id, $status_id = TaskModel::STATUS_OPEN)
{
- return $this->taskFinder->getAll($project_id, $status_id);
+ return $this->formatTasks($this->taskFinder->getAll($project_id, $status_id));
}
public function getOverdueTasks()
@@ -115,4 +115,24 @@ class Task extends Base
list($valid) = $this->taskValidator->validateApiModification($values);
return $valid && $this->taskModification->update($values);
}
+
+ private function formatTask($task)
+ {
+ if (! empty($task)) {
+ $task['url'] = $this->helper->url->base().$this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']));
+ }
+
+ return $task;
+ }
+
+ private function formatTasks($tasks)
+ {
+ if (! empty($tasks)) {
+ foreach ($tasks as &$task) {
+ $task = $this->formatTask($task);
+ }
+ }
+
+ return $tasks;
+ }
}