Exemplo n.º 1
0
 public function init()
 {
     $this->_config = Registry::get("config");
     $this->_session = \Yaf\Session::getInstance();
     $this->_session->start();
     $this->_layout = Registry::get('layout');
 }
Exemplo n.º 2
0
 /**
  * [getCurrentUser description]
  * @return [type] [description]
  */
 public static function getCurrentUser()
 {
     if (!isset(self::$instance)) {
         $session = \Yaf\Session::getInstance();
         if ($session->has('current_id')) {
             $member = self::getByID($session->current_id);
             self::$instance = $member;
         }
     }
     return self::instance();
 }
Exemplo n.º 3
0
 /**
  *  GET Bookinfo on online
  *  @return integer , bookid in the session.
  */
 public function getEditingCurrent()
 {
     $user = \backend\dao\Members::getCurrentUser();
     if (!$user->id) {
         return false;
     }
     $session = \Yaf\Session::getInstance();
     if ($session->has('bid')) {
         return $session->bid;
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * 返回单例模式
  */
 public static function getInstance()
 {
     // CLI模式直接使用Yaf原生自带的Session机制($_SESSION原理一致)
     if (!APPLICATION_IS_CLI) {
         return \Yaf\Session::getInstance();
     }
     // 查看全局空间是否存在实例
     if (!is_null(self::$_instance)) {
         return self::$_instance;
     }
     // 开启模拟Session机制,并注册全局空间
     self::$_instance = new self();
     self::$_instance->start();
     return self::$_instance;
 }
Exemplo n.º 5
0
 public function __construct()
 {
     self::$instance = $this;
     // use yaf session
     $session = $this->session = \Yaf\Session::getInstance();
     // retrieve flashes from prev request
     if ($session->has($this::SESSION_KEY)) {
         // var_dump($session);
         $this->flashes = $session->get($this::SESSION_KEY);
         $session->del($this::SESSION_KEY);
     } else {
         $this->flashes = array();
     }
     $session->set($this::SESSION_KEY, array());
 }
Exemplo n.º 6
0
 /**
  * Init Session Register
  *
  */
 protected function _initSession()
 {
     $session = \Yaf\Session::getInstance();
     \Yaf\Registry::set('Session', $session);
 }
 /**
  * 封装过来的 Session
  *
  * @return \Yaf\Session
  */
 public function getSession()
 {
     return \Yaf\Session::getInstance();
 }
Exemplo n.º 8
0
 /**
  * 初始化用户状态
  */
 protected function initUserInfo()
 {
     define('UID', Session::getInstance()->get('member.uid'));
     define('UNAME', Session::getInstance()->get('member.uname'));
 }
 /**
  * 处理会话
  * Session 直接交由Yaf自带的类去处理.
  */
 public function _initSession()
 {
     $session = Session::getInstance();
     Registry::set('session', $session);
 }
Exemplo n.º 10
0
 public function _initSession(\Yaf\Dispatcher $dispatcher)
 {
     \Yaf\Session::getInstance()->start();
     header('content-type:text/html;charset=utf-8');
 }
Exemplo n.º 11
0
 public function getUserByToken($token)
 {
     $userinfo = $this->userModel->getInfoByToken($token);
     if (isset($userinfo)) {
         $session = Yaf\Session::getInstance();
         $session['userinfo'] = $userinfo;
         return $userinfo;
     }
     return false;
 }
Exemplo n.º 12
0
 public function _init(Yaf\Dispatcher $dispatcher)
 {
     \Yaf\Session::getInstance()->start();
     $this->app = Yaf\Application::app();
 }
Exemplo n.º 13
0
 /**
  * 获取session对象
  * @return \Yaf\Session
  */
 public final function getSession()
 {
     return Session::getInstance();
 }