diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-15 18:31:47 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-15 18:31:47 -0400 |
commit | 67b836164997527b91452b19adbcb8aa3c5decf1 (patch) | |
tree | b5876d311912e97b0592c7e208639f7b52813a75 /app/Controller/Link.php | |
parent | 108e867605dbc7ece4cbcbecc89a674e9c154a9b (diff) |
Refactoring: added controlled middleware and changed response class
Diffstat (limited to 'app/Controller/Link.php')
-rw-r--r-- | app/Controller/Link.php | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/Controller/Link.php b/app/Controller/Link.php index ec7ab1af..d28f5e4e 100644 --- a/app/Controller/Link.php +++ b/app/Controller/Link.php @@ -2,6 +2,8 @@ namespace Kanboard\Controller; +use Kanboard\Core\Controller\PageNotFoundException; + /** * Link controller * @@ -9,20 +11,21 @@ namespace Kanboard\Controller; * @author Olivier Maridat * @author Frederic Guillot */ -class Link extends Base +class Link extends BaseController { /** * Get the current link * * @access private * @return array + * @throws PageNotFoundException */ private function getLink() { $link = $this->link->getById($this->request->getIntegerParam('link_id')); if (empty($link)) { - $this->notfound(); + throw new PageNotFoundException(); } return $link; @@ -32,6 +35,8 @@ class Link extends Base * List of links * * @access public + * @param array $values + * @param array $errors */ public function index(array $values = array(), array $errors = array()) { @@ -56,19 +61,22 @@ class Link extends Base if ($valid) { if ($this->link->create($values['label'], $values['opposite_label']) !== false) { $this->flash->success(t('Link added successfully.')); - $this->response->redirect($this->helper->url->to('link', 'index')); + return $this->response->redirect($this->helper->url->to('link', 'index')); } else { $this->flash->failure(t('Unable to create your link.')); } } - $this->index($values, $errors); + return $this->index($values, $errors); } /** * Edit form * * @access public + * @param array $values + * @param array $errors + * @throws PageNotFoundException */ public function edit(array $values = array(), array $errors = array()) { @@ -97,13 +105,13 @@ class Link extends Base if ($valid) { if ($this->link->update($values)) { $this->flash->success(t('Link updated successfully.')); - $this->response->redirect($this->helper->url->to('link', 'index')); + return $this->response->redirect($this->helper->url->to('link', 'index')); } else { $this->flash->failure(t('Unable to update your link.')); } } - $this->edit($values, $errors); + return $this->edit($values, $errors); } /** |