Remove some code duplication

This commit is contained in:
Frédéric Guillot
2014-12-06 12:33:28 -05:00
parent c79fad62f7
commit 52c1a3b374

View File

@@ -28,15 +28,15 @@ class User extends Base
* *
* @access public * @access public
*/ */
public function login() public function login(array $values = array(), array $errors = array())
{ {
if ($this->acl->isLogged()) { if ($this->acl->isLogged()) {
$this->response->redirect('?controller=app'); $this->response->redirect('?controller=app');
} }
$this->response->html($this->template->layout('user/login', array( $this->response->html($this->template->layout('user/login', array(
'errors' => array(), 'errors' => $errors,
'values' => array(), 'values' => $values,
'no_layout' => true, 'no_layout' => true,
'redirect_query' => $this->request->getStringParam('redirect_query'), 'redirect_query' => $this->request->getStringParam('redirect_query'),
'title' => t('Login') 'title' => t('Login')
@@ -63,13 +63,7 @@ class User extends Base
} }
} }
$this->response->html($this->template->layout('user/login', array( $this->login($values, $errors);
'errors' => $errors,
'values' => $values,
'no_layout' => true,
'redirect_query' => $redirect_query,
'title' => t('Login')
)));
} }
/** /**
@@ -154,13 +148,13 @@ class User extends Base
* *
* @access public * @access public
*/ */
public function create() public function create(array $values = array(), array $errors = array())
{ {
$this->response->html($this->template->layout('user/new', array( $this->response->html($this->template->layout('user/new', array(
'board_selector' => $this->projectPermission->getAllowedProjects($this->acl->getUserId()), 'board_selector' => $this->projectPermission->getAllowedProjects($this->acl->getUserId()),
'projects' => $this->project->getList(), 'projects' => $this->project->getList(),
'errors' => array(), 'errors' => $errors,
'values' => array(), 'values' => $values,
'title' => t('New user') 'title' => t('New user')
))); )));
} }
@@ -186,13 +180,7 @@ class User extends Base
} }
} }
$this->response->html($this->template->layout('user/new', array( $this->create($values, $errors);
'board_selector' => $this->projectPermission->getAllowedProjects($this->acl->getUserId()),
'projects' => $this->project->getList(),
'errors' => $errors,
'values' => $values,
'title' => t('New user')
)));
} }
/** /**