私はDoctrine 2とZF2を使って認証したいと思っています。助けを得るためにZend 2 + doctrine 2 Auth Adapterを使用しましたが、$authService->authenticate($adapter);
と呼び出すたびに、クラス 'が存在しないというエラーが表示されます。Zend2 + Doctrine2認証
私のmodule.config.phpの設定は#t使用されたようです。
'authenticationadapter' => array(
'orm_default' => array(
'objectManager' => 'doctrine.entitymanager.orm_default',
'identityClass' => 'Profile\Entity\User',
'identityProperty' => 'username',
'credentialProperty' => 'password',
),
),
ただし、authServiceでvar_dumpを作成した場合、すべてのセットがnullになります。私は私が行います$ authAdapterからダンプ
$authAdapter = $this->getAuthAdapter();
$authAdapter->setIdentityValue($username);
$authAdapter->setCredentialValue($password);
を呼び出して、ログインをしたい私のサービスで はIdentityValueとCredentialValue が正しく設定されていることを私に伝えます。
$ 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
getAuthAdapterは次のように示しています
public function getAuthAdapter()
{
if (null === $this->authAdapter) {
$this->authAdapter = $this->getServiceManager()
->get('doctrine.authenticationadapter.ormdefault');
}
return $this->authAdapter;
}
だから、いくつかのいずれかの方法を正しくオプションを設定するために私に言うことができますか?
オーケーIの変更を今は 'Zend \ ServiceManager \ ServiceManager :: getはdoctrine.authentication.orm_default'のインスタンスを取得または作成できませんでした。 getterをpublic function getAuthAdapter()に変更します。 { if(null === $ this-> authAdapter){ $ this-> authAdapter = $ this-> getServiceManager() -> get( 'doctrine.authentication 。orm_default '); } return $ this-> authAdapter; ' –
更新された回答を参照 – hohner
ありがとうございました。今問題が残っているのは1つだけです。 '$ authResult = $ authService-> authenticate();の後に空のページがあります。エラーなし、何もありません。 –