ZF-Commons / ZfcUserDoctrineORM

Doctrine2 ORM storage adapter for ZfcUser.
BSD 3-Clause "New" or "Revised" License
89 stars 92 forks source link

The script tried to execute a method or access a property of an incomplete object #30

Closed ghost closed 10 years ago

ghost commented 12 years ago

When i want to get identity from zfcUserAuthentication like this:

$id = $this->zfcUserAuthentication()->getIdentity()->getId();

Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Membre\Entity\Membre" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition

Here is my entity: http://pastebin.com/tw1aC6ZQ

<?php $options = array( 'objectManager' => $this->getEm(), 'objectRepository' => $this->getEm()->getRepository('Membre\Entity\Membre') , 'identityClass' => 'Membre\Entity\Membre', 'identityProperty' => $identityColumn, 'credentialProperty' => 'password'

'credentialCallable' => null

        );
        $doctrineAuthAdapter = new \DoctrineModule\Authentication\Adapter\ObjectRepository($options);

        $doctrineAuthAdapter->setIdentityValue($identity);
        $doctrineAuthAdapter->setCredentialValue($password);

$authenticationService = new \Zend\Authentication\AuthenticationService(); $authResult = $authenticationService->authenticate($doctrineAuthAdapter); ?>

To avoid this error i can do: $authenticationService->getStorage()->write(serialize($identity));

But then, i can't use $this->zfcUserAuthentication()->getIdentity()->getId() : Fatal error: Call to a member function getId() on a non-object

Danielss89 commented 10 years ago

closing this for now. Please reopen if you still have issue.