summaryrefslogtreecommitdiff
path: root/app/Api
diff options
context:
space:
mode:
Diffstat (limited to 'app/Api')
-rw-r--r--app/Api/Procedure/BaseProcedure.php45
-rw-r--r--app/Api/Procedure/MeProcedure.php2
-rw-r--r--app/Api/Procedure/ProjectProcedure.php15
-rw-r--r--app/Api/Procedure/TaskProcedure.php9
4 files changed, 15 insertions, 56 deletions
diff --git a/app/Api/Procedure/BaseProcedure.php b/app/Api/Procedure/BaseProcedure.php
index e31b3027..16ef5e05 100644
--- a/app/Api/Procedure/BaseProcedure.php
+++ b/app/Api/Procedure/BaseProcedure.php
@@ -21,51 +21,6 @@ abstract class BaseProcedure extends Base
UserAuthorization::getInstance($this->container)->check($this->getClassName(), $procedure);
}
- protected function formatTask($task)
- {
- if (! empty($task)) {
- $task['url'] = $this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), '', true);
- $task['color'] = $this->colorModel->getColorProperties($task['color_id']);
- }
-
- return $task;
- }
-
- protected function formatTasks($tasks)
- {
- if (! empty($tasks)) {
- foreach ($tasks as &$task) {
- $task = $this->formatTask($task);
- }
- }
-
- return $tasks;
- }
-
- protected function formatProject($project)
- {
- if (! empty($project)) {
- $project['url'] = array(
- 'board' => $this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id']), '', true),
- 'calendar' => $this->helper->url->to('CalendarController', 'show', array('project_id' => $project['id']), '', true),
- 'list' => $this->helper->url->to('TaskListController', 'show', array('project_id' => $project['id']), '', true),
- );
- }
-
- return $project;
- }
-
- protected function formatProjects($projects)
- {
- if (! empty($projects)) {
- foreach ($projects as &$project) {
- $project = $this->formatProject($project);
- }
- }
-
- return $projects;
- }
-
protected function filterValues(array $values)
{
foreach ($values as $key => $value) {
diff --git a/app/Api/Procedure/MeProcedure.php b/app/Api/Procedure/MeProcedure.php
index 3ba73fdd..5a64cdb3 100644
--- a/app/Api/Procedure/MeProcedure.php
+++ b/app/Api/Procedure/MeProcedure.php
@@ -62,6 +62,6 @@ class MeProcedure extends BaseProcedure
$project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId());
$projects = $this->projectModel->getAllByIds($project_ids);
- return $this->formatProjects($projects);
+ return $this->projectsApiFormatter->withProjects($projects)->format();
}
}
diff --git a/app/Api/Procedure/ProjectProcedure.php b/app/Api/Procedure/ProjectProcedure.php
index e8a34cd3..c9ac0ae6 100644
--- a/app/Api/Procedure/ProjectProcedure.php
+++ b/app/Api/Procedure/ProjectProcedure.php
@@ -15,33 +15,34 @@ class ProjectProcedure extends BaseProcedure
public function getProjectById($project_id)
{
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProjectById', $project_id);
- return $this->formatProject($this->projectModel->getById($project_id));
+ $project = $this->projectModel->getById($project_id);
+ return $this->projectApiFormatter->withProject($project)->format();
}
public function getProjectByName($name)
{
$project = $this->projectModel->getByName($name);
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProjectByName', $project['id']);
- return $this->formatProject($project);
+ return $this->projectApiFormatter->withProject($project)->format();
}
public function getProjectByIdentifier($identifier)
{
- $project = $this->formatProject($this->projectModel->getByIdentifier($identifier));
+ $project = $this->projectModel->getByIdentifier($identifier);
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProjectByIdentifier', $project['id']);
- return $this->formatProject($project);
+ return $this->projectApiFormatter->withProject($project)->format();
}
public function getProjectByEmail($email)
{
- $project = $this->formatProject($this->projectModel->getByEmail($email));
+ $project = $this->projectModel->getByEmail($email);
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProjectByEmail', $project['id']);
- return $this->formatProject($project);
+ return $this->projectApiFormatter->withProject($project)->format();
}
public function getAllProjects()
{
- return $this->formatProjects($this->projectModel->getAll());
+ return $this->projectsApiFormatter->withProjects($this->projectModel->getAll())->format();
}
public function removeProject($project_id)
diff --git a/app/Api/Procedure/TaskProcedure.php b/app/Api/Procedure/TaskProcedure.php
index 847d336f..b1ea0516 100644
--- a/app/Api/Procedure/TaskProcedure.php
+++ b/app/Api/Procedure/TaskProcedure.php
@@ -24,19 +24,22 @@ class TaskProcedure extends BaseProcedure
public function getTask($task_id)
{
TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id);
- return $this->formatTask($this->taskFinderModel->getById($task_id));
+ $task = $this->taskFinderModel->getById($task_id);
+ return $this->taskApiFormatter->withTask($task)->format();
}
public function getTaskByReference($project_id, $reference)
{
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTaskByReference', $project_id);
- return $this->formatTask($this->taskFinderModel->getByReference($project_id, $reference));
+ $task = $this->taskFinderModel->getByReference($project_id, $reference);
+ return $this->taskApiFormatter->withTask($task)->format();
}
public function getAllTasks($project_id, $status_id = TaskModel::STATUS_OPEN)
{
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getAllTasks', $project_id);
- return $this->formatTasks($this->taskFinderModel->getAll($project_id, $status_id));
+ $tasks = $this->taskFinderModel->getAll($project_id, $status_id);
+ return $this->tasksApiFormatter->withTasks($tasks)->format();
}
public function getOverdueTasks()