Is the parent constructor being called? BTW, AK was made to be compatible with PHP 4, which doesn't have __constructor.
Is the parent constructor being called?
yes... well, actually, constructor creates this error(I mean, if I create:
function __construct(){
$this->user = new User;
if(!$this->user->isAdmin() ){
$this->redirectTo(array('controller'=>'user', 'action'=>'login') );
}
}
I've got the same result as with calling $this->checkUser(); )
Sorry if I'm being dense, but are you calling the constructor for AkApplicationController ?
I think you have to call the parent constructor before you make calls to the model.
Maybe Bermi can shed some light.
@kkrzyzak You might better user a controller filter like:
function __construct(){
$this->beforeFilter(array('_authenticate'=>array('except'=>array('authenticate'))));
}
function _authenticate(){
$this->user = new User;
if(!$this->user->isAdmin()){
$this->redirectTo(array('controller'=>'user', 'action'=>'login') );
return false;
}
}
You can read more about Akelos controller filters on the wiki.
Thanks bermi.
thanks bermi, it works ;)
1 to 11 of 11