本文整理汇总了PHP中yii::createObject方法的典型用法代码示例。如果您正苦于以下问题:PHP yii::createObject方法的具体用法?PHP yii::createObject怎么用?PHP yii::createObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii
的用法示例。
在下文中一共展示了yii::createObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getService
/**
* @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];
}
示例2: _init
/**
* 自定义初始化组件方法
* @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);
}
}
示例3: init
/**
* @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.');
}
}
示例4: getContainer
/**
* Get dropdown container
*
* @return Container
*/
public function getContainer()
{
$container = \yii::createObject(array_merge(['class' => Container::className()], $this->containerOptions, ['owner' => $this]));
return $container;
}
示例5: OnAfterLogin
/**
* 登陆事件
* @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);
}