yii\web\DbSession::init PHP Method

init() public method

This method will initialize the [[db]] property to make sure it refers to a valid DB connection.
public init ( )
    public function init()
    {
        parent::init();
        $this->db = Instance::ensure($this->db, Connection::className());
    }

Usage Example

Example #1
0
 public function init()
 {
     if (is_string($this->db)) {
         $this->db = Yii::$app->get($this->db);
     }
     if (!$this->db instanceof Connection) {
         throw new InvalidConfigException("DbSession::db must be either a DB connection instance or the application component ID of a DB connection.");
     }
     if (!$this->sessionTable) {
         $this->sessionTable = $this->db->tablePrefix . 'session';
     }
     parent::init();
 }
All Usage Examples Of yii\web\DbSession::init