I have a Zend 2 installation with Doctrine 2 as my ORM.
At the moment I try to implement a authentication with doctrine2.
This works.
But now I want to check in the layout.phtml if the user is logged in or not.
I don't know how to access the authentifcation service from the layout.phtml On this page (https://github.com/doctrine/DoctrineModule/blob/master/docs/authentication.md) they say $this->identity()
But this didn't work. It returns every time NULL.
module.config.php
'authentication' => array(
'orm_default' => array(
'object_manager' => 'Doctrine\ORM\EntityManager',
'identity_class' => 'Application\Model\User',
'identity_property' => 'id',
'credential_property' => 'password'
),
),
Module.php
public function getServiceConfig()
{
return array(
'factories'=>array(
'Application\Model\AuthStorage' => function($sm){
return new \Application\Model\AuthStorage('site');
},
'Zend\Authentication\AuthenticationService' => function($serviceManager) {
return $serviceManager->get('doctrine.authenticationservice.orm_default');
},
),
);
}