Пример #1
0
 /**
  * @param \yii\base\Action $action
  * @return bool
  * @throws \yii\base\InvalidConfigException
  * @throws \yii\web\BadRequestHttpException
  */
 public function beforeAction($action)
 {
     /**
      * ssdb 测试监听的是8883端口
      */
     $this->ssdb = \Yii::createObject(['class' => Connection::className(), 'host' => 'localhost', 'port' => 8883]);
     // 准备捕获action的输出
     ob_start();
     return parent::beforeAction($action);
 }
Пример #2
0
 public function init()
 {
     parent::init();
     if (is_string($this->ssdb)) {
         $this->ssdb = \Yii::$app->get($this->ssdb);
     } elseif (is_array($this->ssdb)) {
         if (!isset($this->ssdb['class'])) {
             $this->ssdb['class'] = Connection::className();
         }
         $this->ssdb = \Yii::createObject($this->ssdb);
     }
     if (!$this->ssdb instanceof Connection) {
         throw new InvalidConfigException("Session::ssdb must be either a Ssdb Connection instance or the application component ID of a ssdb Connection.");
     }
     if ($this->key_prefix === null) {
         $this->key_prefix = substr(md5(Yii::$app->id), 0, 5);
     }
 }