db = \Zend_Registry::get('db'); }else{ $this->db = $db; } $this->config = \Zend_Registry::get('config'); $this->table = new Table(); } //获得Handler,type必须与 \Open\Source中同步,否则会出现错误 // public function getHandler($type,$data) { if($type == 'escience') { return new \Open\Handler\ClientTokenHandler\Escience($data); } if($type == 'sina') { return new \Open\Handler\ClientTokenHandler\Sina($data); } return false; } //存储token信息 public function tokenAndDataStorage(\Zend_EventManager_Event $e) { $type = $e->getParam('type'); $data = $e->getParam('token'); $handler = $this->getHandler($type,$data); if($status = $handler->doit() === true) { return true; }else{ return $status; } } //检查用户账户是否存在 //存在就返回用户信息,不存在返回false //通用事件,通过各个 TokenHandler中内置Listener直接挂载,不需要引入整个ClientListener public function userCheck(\Zend_EventManager_Event $e) { $email = $e->getParam('email'); $user = new Users(); $current = $user->userExists($email); if($current === false) { return false; } return $current; } }