Better docblock type hinting for stores.

This commit is contained in:
Dan Cryer 2013-10-08 18:24:20 +01:00
commit d060227fbd
10 changed files with 105 additions and 50 deletions

View file

@ -21,9 +21,14 @@ use b8\Form;
*/
class UserController extends \PHPCI\Controller
{
/**
* @var \PHPCI\Store\UserStore
*/
protected $userStore;
public function init()
{
$this->_userStore = b8\Store\Factory::getStore('User');
$this->userStore = b8\Store\Factory::getStore('User');
}
/**
@ -31,7 +36,7 @@ class UserController extends \PHPCI\Controller
*/
public function index()
{
$users = $this->_userStore->getWhere(array(), 1000, 0, array(), array('email' => 'ASC'));
$users = $this->userStore->getWhere(array(), 1000, 0, array(), array('email' => 'ASC'));
$this->view->users = $users;
return $this->view->render();
@ -72,7 +77,7 @@ class UserController extends \PHPCI\Controller
$user = new User();
$user->setValues($values);
$user = $this->_userStore->save($user);
$user = $this->userStore->save($user);
header('Location: '.PHPCI_URL.'user');
die;
@ -88,7 +93,7 @@ class UserController extends \PHPCI\Controller
}
$method = $this->request->getMethod();
$user = $this->_userStore->getById($userId);
$user = $this->userStore->getById($userId);
if ($method == 'POST') {
$values = $this->getParams();
@ -116,7 +121,7 @@ class UserController extends \PHPCI\Controller
}
$user->setValues($values);
$user = $this->_userStore->save($user);
$user = $this->userStore->save($user);
header('Location: '.PHPCI_URL.'user');
die;
@ -178,8 +183,8 @@ class UserController extends \PHPCI\Controller
throw new \Exception('You do not have permission to do that.');
}
$user = $this->_userStore->getById($userId);
$this->_userStore->delete($user);
$user = $this->userStore->getById($userId);
$this->userStore->delete($user);
header('Location: '.PHPCI_URL.'user');
die;