내가 doctrine.I 모든 부트 스트랩이 제대로 수행되고 난에 로그인 할 수 있습니다 믿습니다 사용하여 프로젝트와 Zend_Auth를 사용하고 있습니다를 받고Doctrine 어댑터를 사용할 때 Zend_Auth/Zend_ACL에서 역할을 얻는 방법은 무엇입니까? . 함께 모든 작업
내 어댑터는 다음과 같습니다
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의 모습을 이
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 치명적인 오류를 갖는 spl_autoload를() function.spl-자동로드] Doctrine_Event 클래스를로드 할 수 없습니다. 나는이 post here을 봤고 그게 Zend_Session을 사용하는 것에 어떻게 영향을 미칠지 궁금하네요. 이걸 읽으려면 내 php.thanks에서 많이 사용하도록 하는게 사실이에요.
이 모든 것을 쓰는 시간 동안 고마워. 내 게시물을 편집하여 질문 2를 더 분명하게 만듭니다. –
안녕하세요 저는 아이디어를 구현할 때 발견 된 결과와 문제로 스크립트를 업데이트했습니다. 다른 사람들이 지금부터 단계적으로 자신의 경험을 공유 할 수 있기를 바랍니다. 어쨌든 –
역할이 배열입니까? 사용자 모델은 hasMany ('Role')로 정의되어 있습니까? 별도의 생각으로 왜 Auth 어댑터가 모든 것을 배열로 변환하려고하는지 알고 싶습니다. Doctrine은 객체 그래프를 생성합니다. 왜 그것을 지키지 않습니까? –