/** * Initialize * @throws \yii\base\InvalidConfigException */ public function init() { parent::init(); $this->db = Instance::ensure($this->db, Connection::className()); $this->authManager = Instance::ensure($this->authManager, BaseManager::className()); $this->user = Instance::ensure($this->user, User::className()); if (empty($this->cache)) { $this->cache = $this->createCacheComponent(); } else { $this->cache = Instance::ensure($this->cache, Cache::className()); } }
/** * Initialise component. */ public function init() { parent::init(); try { $this->db = Instance::ensure($this->db, Connection::className()); if ($this->db->driverName === 'mysql') { $this->setTableOptions('CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'); } $this->authManager = Instance::ensure($this->authManager, BaseManager::className()); } catch (Exception $e) { Yii::error([$e->getName(), $e->getMessage()], __METHOD__); } }