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


PHP Controller::init方法代碼示例

本文整理匯總了PHP中yii\web\Controller::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP Controller::init方法的具體用法?PHP Controller::init怎麽用?PHP Controller::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\web\Controller的用法示例。


在下文中一共展示了Controller::init方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 public function init()
 {
     parent::init();
     $model = new Category();
     $map = ['status' => 1];
     $model->getList($map);
 }
開發者ID:xiaoneng1988,項目名稱:learn,代碼行數:7,代碼來源:BaseController.php

示例2: init

 public function init()
 {
     parent::init();
     if ($user = Yii::$app->getUser()) {
         $this->auth_user = $user->identity;
     }
 }
開發者ID:Kulkow,項目名稱:mainsite,代碼行數:7,代碼來源:AdminLayoutController.php

示例3: init

 public function init()
 {
     parent::init();
     $this->titleMeta = Yii::$app->name;
     $this->siteNameMeta = Yii::$app->name;
     $this->descriptionMeta = Yii::t('app', 'Free classifieds from all over the world !!!');
 }
開發者ID:baranov-nt,項目名稱:setyes,代碼行數:7,代碼來源:BehaviorsController.php

示例4: init

 public function init()
 {
     parent::init();
     //CSRF 基於 POST 驗證,UEditor 無法添加自定義 POST 數據,同時由於這裏不會產生安全問題,故簡單粗暴地取消 CSRF 驗證。
     //如需 CSRF 防禦,可以使用 server_param 方法,然後在這裏將 Get 的 CSRF 添加到 POST 的數組中。。。
     Yii::$app->request->enableCsrfValidation = false;
     //當客戶使用低版本IE時,會使用swf上傳插件,維持認證狀態可以參考文檔UEditor「自定義請求參數」部分。
     //http://fex.baidu.com/ueditor/#server-server_param
     //保留UE默認的配置引入方式
     if (file_exists(__DIR__ . '/config.json')) {
         $CONFIG = json_decode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", '', file_get_contents(__DIR__ . '/config.json')), true);
     } else {
         $CONFIG = [];
     }
     if (!is_array($this->config)) {
         $this->config = [];
     }
     if (!is_array($CONFIG)) {
         $CONFIG = [];
     }
     $default = ['imagePathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'scrawlPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'snapscreenPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'catcherPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'videoPathFormat' => '/upload/video/{yyyy}{mm}{dd}/{time}{rand:8}', 'filePathFormat' => '/upload/file/{yyyy}{mm}{dd}/{rand:8}_{filename}', 'imageManagerListPath' => '/upload/image/', 'fileManagerListPath' => '/upload/file/'];
     $this->config = $this->config + $default + $CONFIG;
     $this->webroot = Yii::getAlias('@webroot');
     if (!is_array($this->thumbnail)) {
         $this->thumbnail = false;
     }
 }
開發者ID:136216444,項目名稱:Yii2-UEditor,代碼行數:27,代碼來源:UEditorController.php

示例5: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->modelTitleForms)) {
         $this->modelTitleForms = PhpMorphy::getNeededForms($this->modelTitle);
     }
 }
開發者ID:e96,項目名稱:yii2-madmin,代碼行數:10,代碼來源:MAdminController.php

示例6: init

 public function init()
 {
     parent::init();
     $extJsSrcDir = Yii::getAlias($this->extJsDir);
     $extJsSrcExtendDir = Yii::getAlias($this->extJsExtendDir);
     $dstDir = Yii::getAlias($this->dstPath);
     $extJsDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs';
     $extJsExtendDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs-extend';
     if (!is_dir($dstDir)) {
         if (!is_dir($dstDir)) {
             FileHelper::createDirectory($dstDir);
         }
     }
     if (!is_dir($extJsDstDir)) {
         symlink($extJsSrcDir, $extJsDstDir);
     }
     if (!is_dir($extJsExtendDstDir)) {
         symlink($extJsSrcExtendDir, $extJsExtendDstDir);
     }
     $data = DpConfig::find()->all();
     $config = [];
     foreach ($data as $item) {
         $config[$item['name']] = $item['value'];
     }
     $this->config = $config;
     $this->identity = Yii::$app->user->identity;
 }
開發者ID:phpsong,項目名稱:yii2-extjs-rbac,代碼行數:27,代碼來源:Controller.php

示例7: init

 public function init()
 {
     $this->setRequestParams(Yii::$app->request);
     $this->setPageParams($this->requestParams);
     $this->setSortParams($this->requestParams);
     parent::init();
 }
開發者ID:xiaomige,項目名稱:giishop,代碼行數:7,代碼來源:BaseController.php

示例8: init

 /**
  * Initializes the object.
  * This method is invoked at the end of the constructor after the object is initialized with the
  * given configuration.
  */
 public function init()
 {
     $response = \Yii::$app->response;
     $response->format = \yii\web\Response::FORMAT_JSON;
     parent::init();
     // TODO: Change the autogenerated stub
 }
開發者ID:axiles89,項目名稱:amop,代碼行數:12,代碼來源:AjaxController.php

示例9: init

 /**
  * Creates inherited user account.
  */
 public function init()
 {
     parent::init();
     if (!Yii::$app->user->isGuest) {
         if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
             $user = User::findMe();
             if (empty($user)) {
                 $new = new User();
                 $new->setScenario('installation');
                 $new->inherited_id = Yii::$app->user->id;
                 $new->status = User::STATUS_ACTIVE;
                 $new->role = User::ROLE_MEMBER;
                 $new->timezone = User::DEFAULT_TIMEZONE;
                 if ($new->save()) {
                     $this->success(Yii::t('podium/flash', Messages::ACCOUNT_INHERITED, ['link' => Html::a(Yii::t('podium/layout', 'Profile'))]));
                     Cache::clearAfterActivate();
                     Log::info('Inherited account created', $new->id, __METHOD__);
                 } else {
                     throw new Exception(Yii::t('podium/view', Messages::ACCOUNT_INHERITED_ERROR));
                 }
             } elseif ($user->status == User::STATUS_BANNED) {
                 return $this->redirect(['default/ban']);
             }
         } else {
             $user = Yii::$app->user->identity;
         }
         if ($user && !empty($user->timezone)) {
             Yii::$app->formatter->timeZone = $user->timezone;
         }
     }
 }
開發者ID:Avenger1,項目名稱:yii2-podium,代碼行數:34,代碼來源:BaseController.php

示例10: init

 public function init()
 {
     if (Yii::$app->user->isGuest || Yii::$app->user->id > 5) {
         die("Доступ закрыт! Вы не являетесь админом.");
     }
     parent::init();
 }
開發者ID:Nechhist,項目名稱:to.ru,代碼行數:7,代碼來源:AdminBaseController.php

示例11: init

 /**
  * Init function
  */
 public function init()
 {
     parent::init();
     if ($this->userClassName === null) {
         $this->userClassName = Yii::$app->getUser()->identityClass;
     }
 }
開發者ID:rockefys,項目名稱:yii2-rbac,代碼行數:10,代碼來源:AssignmentController.php

示例12: init

 public function init()
 {
     parent::init();
     Yii::$app->language = Yii::$app->user->isGuest ? "en-US" : Yii::$app->user->getIdentity()->language;
     Yii::$app->formatter->datetimeFormat = Yii::$app->user->isGuest ? "dd/MM/yyyy HH:mm" : Yii::$app->user->getIdentity()->date_format . " " . Yii::$app->user->getIdentity()->time_format;
     Yii::$app->formatter->timeZone = Yii::$app->user->isGuest ? 'America/Sao_Paulo' : Yii::$app->user->getIdentity()->time_zone;
 }
開發者ID:ufrgs-hyman,項目名稱:meican,代碼行數:7,代碼來源:BaseController.php

示例13: init

 public function init()
 {
     parent::init();
     $this->modularityService = LuLu::getService('modularity');
     $this->rbacService = LuLu::getService('rbac');
     $this->taxonomyService = LuLu::getService('taxonomy');
 }
開發者ID:hucongyang,項目名稱:lulucms2,代碼行數:7,代碼來源:BaseController.php

示例14: init

 /**
  * 初始化
  * @see \yii\base\Object::init()
  */
 public function init()
 {
     parent::init();
     //初始化web目錄下的資源路徑
     $this->baseUrl = Yii::getAlias('@web');
     $this->layout = '@app/views/layouts/adminlte_main';
 }
開發者ID:xidiao,項目名稱:gxfenxi,代碼行數:11,代碼來源:AdminlteController.php

示例15: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $this->user_id = $this->module->userId;
     $this->notificationClass = $this->module->notificationClass;
     parent::init();
 }
開發者ID:michaelst,項目名稱:yii2-notifications,代碼行數:10,代碼來源:NotificationsController.php


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