當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Component::init方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:euromd,項目名稱:yii2-yandex-metrika,代碼行數:7,代碼來源:Client.php

示例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.');
     }
 }
開發者ID:filsh,項目名稱:yii2-platform,代碼行數:7,代碼來源:Locale.php

示例3: init

 public function init()
 {
     parent::init();
     if (Yii::$app->view !== null) {
         Yii::$app->view->on(yii\web\View::EVENT_BEGIN_PAGE, [$this, 'eventSetMeta']);
     }
 }
開發者ID:shershennm,項目名稱:yii2-seo,代碼行數:7,代碼來源:Seo.php

示例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]);
 }
開發者ID:didwjdgks,項目名稱:yii2-ebid-lh,代碼行數:7,代碼來源:SucWatcher.php

示例5: init

 /**
  * Initializes the object
  */
 public function init()
 {
     parent::init();
     if (substr($this->iniDirectory, 0, 1) === '@') {
         $this->iniDirectory = Yii::getAlias($this->iniDirectory);
     }
 }
開發者ID:pombredanne,項目名稱:xunsearch,代碼行數:10,代碼來源:Connection.php

示例6: init

 public function init()
 {
     parent::init();
     if (empty($this->_list)) {
         $this->_list = ['@nullref/cms/views/layouts/clear' => Yii::t('cms', 'Base layout')];
     }
 }
開發者ID:NullRefExcep,項目名稱:yii2-cms,代碼行數:7,代碼來源:PageLayoutManager.php

示例7: init

 public function init()
 {
     parent::init();
     if (!$this->executePath) {
         $this->executePath = \Yii::getAlias('@app');
     }
 }
開發者ID:nagser,項目名稱:base,代碼行數:7,代碼來源:ConsoleManager.php

示例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;
     }
 }
開發者ID:best-nazar,項目名稱:gb-yii2,代碼行數:35,代碼來源:languageSwitcher.php

示例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]);
 }
開發者ID:didwjdgks,項目名稱:yii2-kepco,代碼行數:7,代碼來源:Http.php

示例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後台-應用設置中查找');
     }
 }
開發者ID:chenyuzou,項目名稱:yii2-ucenter,代碼行數:7,代碼來源:Client.php

示例11: init

 /**
  * 
  * */
 public function init()
 {
     if ($this->OpcTabModelClass === null) {
         throw new InvalidConfigException('Orcsis::OpcTabModelClass must be set.');
     }
     parent::init();
 }
開發者ID:orcsis,項目名稱:yii2-orcsis,代碼行數:10,代碼來源:Orcsis.php

示例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;
     }
 }
開發者ID:YiiVN,項目名稱:Yii2-Image,代碼行數:28,代碼來源:ImageCache.php

示例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);
     }
 }
開發者ID:lianghongle,項目名稱:yii2-zh-cn,代碼行數:11,代碼來源:Cache.php

示例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);
     }
 }
開發者ID:br0sk,項目名稱:yii2-ironmq,代碼行數:32,代碼來源:IronMQ.php

示例15: init

 public function init()
 {
     parent::init();
     if ($this->modulename == null) {
         throw new InvalidParamException('modulename parameter for plathir\\settings\\components cannot set.');
     }
 }
開發者ID:plathir,項目名稱:yii2-smart-settings,代碼行數:7,代碼來源:Settings.php


注:本文中的yii\base\Component::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。