/** * @return mixed * @throws \yii\base\InvalidConfigException */ public static function getService() { $class_name = static::className(); if (!isset(static::$_services[$class_name]) || !static::$_services[$class_name] instanceof Service) { static::$_services[$class_name] = \yii::createObject($class_name); } return static::$_services[$class_name]; }
/** * 自定义初始化组件方法 * @throws InvalidConfigException */ private function _init() { if (!static::$mobCompenent instanceof \common\compenents\MobileCode) { //注册mob组件 $_conf = ['class' => \common\compenents\MobileCode::className()]; $_conf = array_merge($_conf, \common\helpers\CommonHelper::loadConfig('mobConf')); static::$mobCompenent = \yii::createObject($_conf); } }
/** * @inheritdoc */ public function init() { parent::init(); if (is_string($this->redis)) { $this->redis = \yii::$app->get($this->redis); } if (is_array($this->redis)) { $this->redis = yii::createObject($this->redis); } if ($this->redis === null) { throw new InvalidConfigException('The "redis" property must be set.'); } }
/** * Get dropdown container * * @return Container */ public function getContainer() { $container = \yii::createObject(array_merge(['class' => Container::className()], $this->containerOptions, ['owner' => $this])); return $container; }
/** * 登陆事件 * @param int $user * @param string $client_type * @throws \yii\base\InvalidConfigException */ private function OnAfterLogin($user, $client_type = NULL) { $_config = ['class' => '\\backend\\events\\LoginEvent', 'userId' => $user->id, 'loginTime' => time(), 'loginIp' => \yii::$app->getRequest()->userIP, 'clientType' => $client_type]; $user_event = \yii::createObject($_config); $this->trigger(static::AFTER_LOGIN_EVENT, $user_event); }