Ejemplo n.º 1
0
 /**
  * 初始化DbSession组件。
  * 该方法会初始化db属性,以确保它是一个合法的数据库连接。
  * @throws \Exception 如果{@link db}非法
  */
 public function init()
 {
     if (is_string($this->db)) {
         $this->db = Sky::$app->getComponent($this->db);
     }
     if (!$this->db instanceof ConnectionPool) {
         throw new \Exception("DbSession::db must be either a DB connection instance or the application component ID of a DB connection.");
     }
     parent::init();
 }
Ejemplo n.º 2
0
 /**
  * 初始化
  */
 public function init()
 {
     if (is_string($this->cache)) {
         $this->cache = Sky::$app->getComponent($this->cache);
     }
     if (!$this->cache instanceof Cache) {
         throw new \Exception('CacheSession::cache must refer to the application component ID of a cache object.');
     }
     parent::init();
 }