I would like to have authentication using Doctrine 2 and ZF2. To get some help, I used the Zend 2 + doctrine 2 Auth Adapter , but every time I call $authService->authenticate($adapter); , I get an error that the class '' does not exist.
It seems that the config from my module.config.php won # t. It shows the following:
'authenticationadapter' => array( 'orm_default' => array( 'objectManager' => 'doctrine.entitymanager.orm_default', 'identityClass' => 'Profile\Entity\User', 'identityProperty' => 'username', 'credentialProperty' => 'password', ), ),
But if I did var_dump in authService, all sets are null. In my service, where I want to login, I call
$authAdapter = $this->getAuthAdapter(); $authAdapter->setIdentityValue($username); $authAdapter->setCredentialValue($password);
A dump from $ authAdapter tells me that IdentityValue and CredentialValue are set correctly.
Other things in $ authAdabter:
protected 'options' => object(DoctrineModule\Options\Authentication)[281] protected 'objectManager' => object(Doctrine\ORM\EntityManager)[248] private 'config' => object(Doctrine\ORM\Configuration)[250] ... private 'conn' => object(Doctrine\DBAL\Connection)[252] ... private 'metadataFactory' => object(Doctrine\ORM\Mapping\ClassMetadataFactory)[266] ... private 'repositories' => array (size=0) ... private 'unitOfWork' => object(Doctrine\ORM\UnitOfWork)[267] ... private 'eventManager' => object(Doctrine\Common\EventManager)[242] ... private 'hydrators' => array (size=0) ... private 'proxyFactory' => object(Doctrine\ORM\Proxy\ProxyFactory)[268] ... private 'expressionBuilder' => null private 'closed' => boolean false private 'filterCollection' => null protected 'objectRepository' => null protected 'identityClass' => null protected 'identityProperty' => null protected 'credentialProperty' => null protected 'credentialCallable' => null protected 'classMetadata' => null protected 'storage' => null protected '__strictMode__' => boolean true protected 'authenticationResultInfo' => null
The getAuth attribute is as follows:
public function getAuthAdapter() { if (null === $this->authAdapter) { $this->authAdapter = $this->getServiceManager() ->get('doctrine.authenticationadapter.ormdefault'); } return $this->authAdapter; }
So can someone tell me how to set the parameters correctly?