をすべての作業を取得し、すべてのブートストラップが正しく行われていると私は、ログインすることができます信じているDoctrineアダプタを使用する場合のZend_Auth/Zend_ACLからの役割の取得方法は?私はdoctrine.Iを使用してプロジェクトににZend_Authを使用しています一緒に
私のアダプタは次のようになります。
class Abra_Auth_Adapter_Doctrine implements Zend_Auth_Adapter_Interface {
protected $_resultArray;
private $username;
private $password;
public function __construct($username, $password) {
$this->username = $username;
$this->password = $password;
}
//based on feedbacks as response authenticate has changed to this
public function authenticate() {
$q = Doctrine_Query::create()
->from("Abra_Model_User u")
->leftJoin("u.Role r")
->where("u.username=? AND u.password=?", array($this->username,$this->password));
$result = $q->execute();
if (count($result) == 1) {
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result->get("Mylibrary_Model_User"), array());//autoloaderNamespaces[] = "Mylibrary_" in application.ini
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null, array("Authentication Unsuccessful"));
}
}
私Abra_Controller_Pluging_Aclのルックスspl_autoload()[function.spl-のautoload]:今Doctrine_Eventは致命的なエラーを持つこの
class Abra_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) {
parent::preDispatch($request);
$controller = $request->getControllerName();
$action = $request->getActionName();
$module = $request->getModuleName();
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity()){
$identity = $auth->getIdentity();
$roles = $identity["Role"];
$role = $roles["name"];
$role = (empty ($role) || is_null($role))? "regular" : $role ;
} else {
$role = "guest";
}
}
ようなクラスDoctrine_Eventはロードできませんでした。私はこれを見たpost hereと私はZend_Sessionの私の使用に影響を与えることができ、それは私のphp.thanksでこれを読むために多くを有効にしていることを真実だと思っています
私はこのすべてを書くのに感謝しています。 –
こんにちは私はあなたのアイデアを実装したときに見つかった結果と問題でスクリプトを更新しました。他の人が今から踏み込んで自分のexperience.thanksを共有できることを願っています –
役割は配列ですか?ユーザーモデルはhasMany( 'Role')で定義されていますか?別の考えとして、authアダプターがすべてを配列に変換する理由を教えてください。 Doctrineはオブジェクトグラフを作成します。なぜそれを保つのですか? –