summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-26 21:30:21 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-26 21:30:21 -0500
commit52b9899fc564f7fce572790ede5e59b30b09875c (patch)
treed6ad85bff02aea37b9da88682cd0d7824fb2f6b1 /app/Controller
parent3ba8e066328866d7446e1167fd35ecf2bdc4351e (diff)
Remove some code duplication
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Category.php27
1 files changed, 8 insertions, 19 deletions
diff --git a/app/Controller/Category.php b/app/Controller/Category.php
index d69ed115..27c0d9fc 100644
--- a/app/Controller/Category.php
+++ b/app/Controller/Category.php
@@ -34,14 +34,14 @@ class Category extends Base
*
* @access public
*/
- public function index()
+ public function index(array $values = array(), array $errors = array())
{
$project = $this->getProjectManagement();
$this->response->html($this->projectLayout('category/index', array(
'categories' => $this->category->getList($project['id'], false),
- 'values' => array('project_id' => $project['id']),
- 'errors' => array(),
+ 'values' => $values + array('project_id' => $project['id']),
+ 'errors' => $errors,
'project' => $project,
'title' => t('Categories')
)));
@@ -70,13 +70,7 @@ class Category extends Base
}
}
- $this->response->html($this->projectLayout('category/index', array(
- 'categories' => $this->category->getList($project['id'], false),
- 'values' => $values,
- 'errors' => $errors,
- 'project' => $project,
- 'title' => t('Categories')
- )));
+ $this->index($values, $errors);
}
/**
@@ -84,14 +78,14 @@ class Category extends Base
*
* @access public
*/
- public function edit()
+ public function edit(array $values = array(), array $errors = array())
{
$project = $this->getProjectManagement();
$category = $this->getCategory($project['id']);
$this->response->html($this->projectLayout('category/edit', array(
- 'values' => $category,
- 'errors' => array(),
+ 'values' => empty($values) ? $category : $values,
+ 'errors' => $errors,
'project' => $project,
'title' => t('Categories')
)));
@@ -120,12 +114,7 @@ class Category extends Base
}
}
- $this->response->html($this->projectLayout('category/edit', array(
- 'values' => $values,
- 'errors' => $errors,
- 'project' => $project,
- 'title' => t('Categories')
- )));
+ $this->edit($values, $errors);
}
/**