本文整理汇总了PHP中yii\base\Component::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::init方法的具体用法?PHP Component::init怎么用?PHP Component::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Component
的用法示例。
在下文中一共展示了Component::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
if (!$this->clientID || !$this->clientSecret) {
throw new InvalidParamException();
}
}
示例2: init
public function init()
{
parent::init();
if (!in_array($this->defaultLocale, $this->enableLocales)) {
throw new \yii\base\InvalidParamException('Default locale must be contained in the enable locales list.');
}
}
示例3: init
public function init()
{
parent::init();
if (Yii::$app->view !== null) {
Yii::$app->view->on(yii\web\View::EVENT_BEGIN_PAGE, [$this, 'eventSetMeta']);
}
}
示例4: init
public function init()
{
parent::init();
$this->module = \ebidlh\Module::getInstance();
$this->pub = \Yii::createObject(['class' => \ebidlh\Redis::className(), 'hostname' => $this->module->redis_server]);
$this->sub = \Yii::createObject(['class' => \ebidlh\Redis::className(), 'hostname' => $this->module->redis_server]);
}
示例5: init
/**
* Initializes the object
*/
public function init()
{
parent::init();
if (substr($this->iniDirectory, 0, 1) === '@') {
$this->iniDirectory = Yii::getAlias($this->iniDirectory);
}
}
示例6: init
public function init()
{
parent::init();
if (empty($this->_list)) {
$this->_list = ['@nullref/cms/views/layouts/clear' => Yii::t('cms', 'Base layout')];
}
}
示例7: init
public function init()
{
parent::init();
if (!$this->executePath) {
$this->executePath = \Yii::getAlias('@app');
}
}
示例8: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!isset(Yii::$app->params['languages'])) {
throw new \yii\base\InvalidConfigException("You must define Yii::\$app->params['languages'] array");
}
foreach (Yii::$app->params['languages'] as $code => $language) {
if (is_array($language)) {
$this->_languages[$code] = $language;
} else {
$this->_languages[$code] = ['queryValue' => $language, 'cookieValue' => $language, 'sessionValue' => $language];
}
}
$queryValue = Yii::$app->request->get($this->queryParam);
$cookieValue = Yii::$app->request->cookies->getValue($this->cookieParam);
$sessionValue = Yii::$app->session->get($this->sessionParam);
if ($queryValue !== null) {
$code = $this->getCode('queryValue', $queryValue);
$config = ['name' => $this->cookieParam, 'value' => $this->_languages[$code]['cookieValue'], 'expire' => time() + 365 * 24 * 60 * 60];
$config = array_merge($config, $this->cookieParams);
Yii::$app->response->cookies->add(new Cookie($config));
Yii::$app->session->set($this->sessionParam, $this->_languages[$code]['sessionValue']);
Yii::$app->language = $code;
} elseif ($cookieValue !== null && $cookieValue !== $sessionValue) {
$code = $this->getCode('cookieValue', $cookieValue);
Yii::$app->session->set($this->sessionParam, $this->_languages[$code]['sessionValue']);
Yii::$app->language = $code;
} elseif ($sessionValue !== null) {
$code = $this->getCode('sessionValue', $sessionValue);
Yii::$app->language = $code;
}
}
示例9: init
public function init()
{
parent::init();
$this->module = \kepco\Module::getInstance();
$this->client = new \GuzzleHttp\Client(['base_uri' => 'http://srm.kepco.net/', 'cookies' => true, 'allow_redirects' => false, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', 'Cookie' => $this->cookie, 'X-CSRF-TOKEN' => $this->token]]);
$this->sub = \Yii::createObject(['class' => \kepco\Redis::className(), 'hostname' => $this->module->redis_server]);
}
示例10: init
public function init()
{
parent::init();
if ($this->key === null || $this->api === null || $this->appid === null) {
throw new InvalidConfigException('UCenter Client appid、api地址、key必须设置,这些参数可以在Ucenter后台-应用设置中查找');
}
}
示例11: init
/**
*
* */
public function init()
{
if ($this->OpcTabModelClass === null) {
throw new InvalidConfigException('Orcsis::OpcTabModelClass must be set.');
}
parent::init();
}
示例12: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!isset($this->sourcePath) || !isset($this->sourceUrl)) {
throw new \yii\base\InvalidConfigException('Invalid sourcePath/sourceUrl.');
}
if (!isset($this->thumbsPath) || !isset($this->thumbsUrl)) {
$this->thumbsPath = '@app/web/thumbs';
$this->thumbsUrl = '@web/thumbs';
}
if (isset($this->text)) {
if (!isset($this->text['text']) || !isset($this->text['fontFile'])) {
throw new \yii\base\InvalidConfigException('Invalid text.');
}
}
$this->sourcePath = Yii::getAlias($this->sourcePath);
$this->sourceUrl = Yii::getAlias($this->sourceUrl);
$this->thumbsPath = Yii::getAlias($this->thumbsPath);
$this->thumbsUrl = Yii::getAlias($this->thumbsUrl);
$this->sourcePath = str_replace('\\', '/', $this->sourcePath);
$this->thumbsPath = str_replace('\\', '/', $this->thumbsPath);
if (!isset($this->resizeMode)) {
$this->resizeMode = ManipulatorInterface::THUMBNAIL_OUTBOUND;
}
}
示例13: init
/**
* Initializes the application component.
* This method overrides the parent implementation by setting default cache key prefix.
*/
public function init()
{
parent::init();
if ($this->keyPrefix === null) {
$this->keyPrefix = substr(md5(Yii::$app->id), 0, 5);
}
}
示例14: init
public function init()
{
parent::init();
//Mandatory config parameters
if (!$this->_projectId) {
throw new InvalidConfigException('ProjectId cannot be empty!');
} else {
$this->configArray['project_id'] = $this->_projectId;
}
if (!$this->_token) {
throw new InvalidConfigException('WriteKey cannot be empty!');
} else {
$this->configArray['token'] = $this->_token;
}
//Optional config parameters
if ($this->_protocol !== null) {
$this->configArray['protocol'] = $this->_protocol;
}
if ($this->_host !== null) {
$this->configArray['host'] = $this->_host;
}
if ($this->_port !== null) {
$this->configArray['port'] = $this->_port;
}
if ($this->_protocol !== null) {
$this->configArray['api_version'] = $this->_apiVersion;
}
//Create a new IronMQ object if it hasn't already been created
if ($this->_ironmq === null) {
$this->_ironmq = new \IronMQ\IronMQ($this->configArray);
}
}
示例15: init
public function init()
{
parent::init();
if ($this->modulename == null) {
throw new InvalidParamException('modulename parameter for plathir\\settings\\components cannot set.');
}
}