初心者向けの包括的なドキュメントは事実上存在しないため、私はZend2用のDoctrineModuleのソースを介して自分の道を歩もうとしています。
そこで、カスタム認証アダプターObjectRepositoryを見つけました。このクラスは、 DoctrineModule \ Options\Authenticationのオブジェクトを取ります。credentialCallable
値をカスタムのBCryptベースの関数に設定する必要があるのはすべてです。
コントローラーがアダプターをラップするためのクラスを作成しました。
namespace User\Controller\Plugin;
class UserAuthentication extends AbstractPlugin {
protected $_authAdapter = null;
protected $_authService = null;
public function __construct($authAdapter) {
$this->setAuthAdapter($authAdapter);
}
// More setters/getters
}
ここで、この呼び出しによって有効なインスタンスが得られるようにモジュールを構成する必要があります。
$uAuth = $this->getServiceLocator()->get('User\Controller\Plugin\UserAuthentication');
当然のことながら、モジュール構成を使用する必要があります。しかし、クラスのインスタンスを適切に作成する方法についてのヒントが見つからなかったため、ここでは完全に完全に立ち往生しています。これは私がこれまでに思いついたものです:
return array(
'di' => array(
'instance' => array(
'User\Event\Authentication' => array(
'parameters' => array(
'userAuthenticationPlugin' => 'User\Controller\Plugin\UserAuthentication',
),
),
'User\Controller\Plugin\UserAuthentication' => array(
'parameters' => array(
'authAdapter' => 'DoctrineModule\Authentication\Adapter\ObjectRepository'
),
),
),
),
'service_manager' => array(
'factories' => array(
'DoctrineModule\Authentication\Adapter\ObjectRepository' => function ($sm) {
/// ????
},
'DoctrineModule\Options\Authentication' => function($sm) {
/// ????
},
),
),
);
だから私はそこに何を記入するのか、あるいはこれが正しい方法でさえあるのかどうかわかりません。これを実行すると、次のようになるため、おそらく私は完全に間違ったパスをたどります。
An abstract factory could not create an instance of usercontrollerpluginuserauthentication(alias: User\Controller\Plugin\UserAuthentication).
アイデアやヒントに感謝します。そして、私に指示したり、同様のものを指示したりしないでくださいZfcUser
。私はこれを自分で実装したい/必要があります。