在ZF 2中显示错误

I am using ZfcUser (https://github.com/ZF-Commons/ZfcUser) module with ZF2. I am logged in using facebook.After log in I am getting below error.

Fatal error: Call to a member function getEmail() on a non-object in D:\php\htdocs\zend_test\module\Dom\view\dom\dom\index.phtml on line 2

The code exists on line 2

<?php echo $this->gravatar($this->zfcUserIdentity()->getEmail()) ?> 

Could anyone say where is the problem?

Thanks

You should always check if the user is logged in. Because otherwise

$this->zfcUserIdentity()

returns null. This is to avoid an error. To check if the user is logged in type

<?php if(!$this->zfcUserIdentity()) {
    echo $this->gravatar($this->zfcUserIdentity()->getEmail());
} ?>

The reason you're not logged is probably in the facebook login implementation.

Source