summaryrefslogtreecommitdiff
path: root/app/Api/Project.php
diff options
context:
space:
mode:
authorLesstat <florianbarth@gmx.de>2015-07-11 11:44:26 +0200
committerLesstat <florianbarth@gmx.de>2015-07-11 11:44:26 +0200
commita85a1c613239c20fe72eb96c2921f4c220ec156b (patch)
treed032b4591e518cbbbfaa8886f8f5d98a6ea2efb7 /app/Api/Project.php
parent5101eaa8060ce3c75a81a26f6e47aae40e3d4ac3 (diff)
parent7e94d0ca233d15d6124c0adf3f956a119c82ccae (diff)
Merged branch 'master' of https://github.com/fguillot/kanboard
only imports conflicted
Diffstat (limited to 'app/Api/Project.php')
-rw-r--r--app/Api/Project.php30
1 files changed, 27 insertions, 3 deletions
diff --git a/app/Api/Project.php b/app/Api/Project.php
index 2451cd9c..faf2a3da 100644
--- a/app/Api/Project.php
+++ b/app/Api/Project.php
@@ -12,17 +12,17 @@ class Project extends Base
{
public function getProjectById($project_id)
{
- return $this->project->getById($project_id);
+ return $this->formatProject($this->project->getById($project_id));
}
public function getProjectByName($name)
{
- return $this->project->getByName($name);
+ return $this->formatProject($this->project->getByName($name));
}
public function getAllProjects()
{
- return $this->project->getAll();
+ return $this->formatProjects($this->project->getAll());
}
public function removeProject($project_id)
@@ -82,4 +82,28 @@ class Project extends Base
list($valid,) = $this->project->validateModification($values);
return $valid && $this->project->update($values);
}
+
+ private function formatProject($project)
+ {
+ if (! empty($project)) {
+ $project['url'] = array(
+ 'board' => $this->helper->url->base().$this->helper->url->to('board', 'show', array('project_id' => $project['id'])),
+ 'calendar' => $this->helper->url->base().$this->helper->url->to('calendar', 'show', array('project_id' => $project['id'])),
+ 'list' => $this->helper->url->base().$this->helper->url->to('listing', 'show', array('project_id' => $project['id'])),
+ );
+ }
+
+ return $project;
+ }
+
+ private function formatProjects($projects)
+ {
+ if (! empty($projects)) {
+ foreach ($projects as &$project) {
+ $project = $this->formatProject($project);
+ }
+ }
+
+ return $projects;
+ }
}