I use Symfony 1.4, Doctrine 1.2 and sfDoctrineGuardPlugin. In actions.class.php i have:
$this->idsfguard = $this->getUser()->getGuardUser()->getId();
if i am logged in this work good, but if i logout then i have error:
Fatal error: Call to a member function
getId() on a non-object in
I tried:
if ($this->getUser()->getGuardUser()->isAuthenticated()){
$this->idsfguard = $this->getUser()->getGuardUser()->getId();
}
but i have error:
Fatal error: Call to a member function
isAuthenticated() on a non-object in
The
isAuthenticated()method is for the sfUser class, not sfGuardUser. And you can only access the sfGuardUser class via sfUser if the user is authenticated.