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


PHP Controller::__construct方法代碼示例

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


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

示例1: __construct

 public function __construct($id, $module, $config = [])
 {
     parent::__construct($id, $module, $config);
     self::$tasks_controllers_folder = __DIR__ . '/../models/';
     self::$tasks_namespace = 'app\\models\\';
     TasksAsset::register($this->view);
 }
開發者ID:MUlt1mate,項目名稱:cron-manager,代碼行數:7,代碼來源:TasksController.php

示例2: __construct

 public function __construct($id, $module = null)
 {
     //驗證用戶是否登錄
     $currentUser = \Yii::$app->session->get(Code::SYS_USER_LOGIN_SESSION);
     $cookieSign = \Yii::$app->request->cookies->getValue(\Yii::$app->params['sys_suiuu_sign']);
     $enPassword = \Yii::$app->params['encryptPassword'];
     $enDigit = \Yii::$app->params['encryptDigit'];
     if (!isset($currentUser) && empty($cookieSign)) {
         return $this->redirect('/login');
     } else {
         if (isset($currentUser)) {
             $this->userObj = $currentUser;
         } else {
             if (!empty($cookieSign)) {
                 $aes = new Aes();
                 $userSign = $aes->decrypt($cookieSign, $enPassword, $enDigit);
                 $this->__sysUserService = new SysUserService();
                 $currentUser = $this->__sysUserService->findUserByUserSign($userSign);
                 if (isset($currentUser)) {
                     $this->userObj = $currentUser;
                     \Yii::$app->session->set(Code::SYS_USER_LOGIN_SESSION, $currentUser);
                 } else {
                     return $this->redirect('/login');
                 }
             }
         }
     }
     parent::__construct($id, $module);
 }
開發者ID:JerryWang304,項目名稱:Web-Backend,代碼行數:29,代碼來源:CController.php

示例3: __construct

 public function __construct($id, $module, $config = [])
 {
     parent::__construct($id, $module, $config = []);
     $view = Yii::$app->view;
     $view->params['id'] = $id;
     $view->params['copyright'] = Yii::$app->params['Copyright'];
     $this->setTitle();
 }
開發者ID:apanly,項目名稱:dream,代碼行數:8,代碼來源:BaseController.php

示例4: __construct

 public function __construct($id, $module, $config = [])
 {
     $this->post = Yii::$app->request->post();
     // 加載數據庫配置
     \Yii::$app->params['category'] = Config::article_category();
     \Yii::$app->params['tag'] = Config::article_tag();
     parent::__construct($id, $module, $config = []);
 }
開發者ID:codekissyoung,項目名稱:filmfest,代碼行數:8,代碼來源:BaseController.php

示例5: __construct

 public function __construct($id, $module)
 {
     parent::__construct($id, $module);
     //        if (!$module->active) {
     //            throw new NotFoundHttpException('The requested app is disabled or not installed.');
     //        }
     // code for check installed application
 }
開發者ID:plathir,項目名稱:my-yii-adv,代碼行數:8,代碼來源:RecipesController.php

示例6: __construct

 public function __construct($id, $module, $config = [])
 {
     //DI容器獲取實例化的對象
     //通過DI容器來創建、獲取實例的。
     $this->advertService = \Yii::createObject('advertservice');
     $this->categoryService = \Yii::createObject('categoryservice');
     $this->productService = \Yii::createObject('productservice');
     parent::__construct($id, $module, $config);
 }
開發者ID:xingfuunit,項目名稱:pzfresh,代碼行數:9,代碼來源:SiteController.php

示例7: __construct

 /**
  * 析構方法
  *
  * @return void
  * @author
  **/
 public function __construct($id, $module, $config = [])
 {
     parent::__construct($id, $module, $config);
     // 設置用戶信息
     $this->set_user();
     // 設置Token
     $this->set_token();
     // 配置文件
     $this->config = Config::get_config();
 }
開發者ID:songhongyu,項目名稱:datecenter,代碼行數:16,代碼來源:AppController.php

示例8: __construct

 public function __construct($id, $module, $config = [])
 {
     if ($this->isNeedLogin) {
         \Yii::$app->session->open();
         $model = new AdminUser();
         if (!$model->checkUserIsLogin()) {
             $this->redirect(Variable::$home_url);
             return;
         }
     }
     parent::__construct($id, $module, $config = []);
 }
開發者ID:jaybril,項目名稱:www.mimgpotea.com,代碼行數:12,代碼來源:BaseController.php

示例9: __construct

 public function __construct($id, $module = null)
 {
     parent::__construct($id, $module);
     // Set the application language if provided by GET, session or cookie
     if (isset($_GET['lang'])) {
         Yii::$app->language = $_GET['lang'];
         Yii::$app->session->set('lang', $_GET['lang']);
         Yii::$app->response->cookies->add(new Cookie(['name' => 'lang', 'value' => $_GET['lang'], 'expire' => time() + 60 * 60 * 24 * 365]));
     } elseif (Yii::$app->session->has('lang')) {
         Yii::$app->language = Yii::$app->session->get('lang', Yii::$app->language);
     } elseif (Yii::$app->request->cookies->getValue('lang')) {
         Yii::$app->language = Yii::$app->request->cookies->getValue('lang', Yii::$app->language);
     }
 }
開發者ID:AstRonin,項目名稱:yii2_improvement,代碼行數:14,代碼來源:Controller.php

示例10: __construct

 public function __construct($id, $module, $config = [])
 {
     //用戶是否登錄判斷
     if (isset($_COOKIE['LoginKey'])) {
         $cookie = $_COOKIE['LoginKey'];
         //LoginKey是登錄憑證
         $sql = "select * from user where cookie = '{$cookie}'";
         $res = \Yii::$app->db->createCommand($sql)->queryAll();
         if ($res) {
             Yii::$app->view->params['user'] = $res[0];
             //已經登錄用戶,保存用戶信息
         }
     }
     // 加載數據庫配置
     \Yii::$app->params['category'] = Config::article_category();
     \Yii::$app->params['tag'] = Config::article_tag();
     parent::__construct($id, $module, $config = []);
 }
開發者ID:codekissyoung,項目名稱:filmfest,代碼行數:18,代碼來源:BaseController.php

示例11: __construct

 public function __construct($id, $module, $config = array())
 {
     if (isset(Yii::$app->request->queryParams['goodType'])) {
         $session = Yii::$app->session;
         $session->open();
         $session['goodType'] = Yii::$app->request->queryParams['goodType'];
         return $this->redirect('/' . $id);
     }
     $session = Yii::$app->session;
     $session->open();
     if (isset($session['goodType']) && strlen($session['goodType']) > 0) {
         $this->goodType = $session['goodType'];
     } else {
         $this->redirect('/goods-type');
     }
     $oGoodType = \app\models\GoodsType::findOne($session['goodType']);
     $this->goodTypeName = $oGoodType->name;
     parent::__construct($id, $module, $config);
 }
開發者ID:A111ex,項目名稱:parser.ru,代碼行數:19,代碼來源:GoodsParamsNameController.php

示例12: array

 function __construct($id, $module, $config = array())
 {
     $session = Yii::$app->session;
     $session->open();
     if (isset(Yii::$app->request->queryParams['goodTypeParam'])) {
         $session['goodTypeParam'] = Yii::$app->request->queryParams['goodTypeParam'];
         return $this->redirect('/' . $id);
     }
     if (isset($session['goodTypeParam']) && strlen($session['goodTypeParam']) > 0) {
         //            $this->goodTypeParam = $session['goodTypeParam'];
     } else {
         $this->redirect('/goods-type');
     }
     $this->oGoodsParamsName = \app\models\GoodsParamsName::findOne($session['goodTypeParam']);
     if (!$this->oGoodsParamsName instanceof \app\models\GoodsParamsName) {
         throw new Exception('Не существует такой тип параметра.');
     }
     $oGoodType = \app\models\GoodsType::findOne($session['goodType']);
     if (!$oGoodType instanceof \app\models\GoodsType) {
         throw new Exception('Не существует такой тип товара.');
     }
     $this->goodTypeName = $oGoodType->name;
     parent::__construct($id, $module, $config);
 }
開發者ID:A111ex,項目名稱:parser.ru,代碼行數:24,代碼來源:GoodsParamsController.php

示例13: __construct

 public function __construct($id, $module, UserValidation $userValidation, $config = [])
 {
     $this->userValidation = $userValidation;
     parent::__construct($id, $module, $config);
 }
開發者ID:przemek207,項目名稱:Nzi_Project,代碼行數:5,代碼來源:OrderController.php

示例14: __construct

 public function __construct($id, $module, $config = [])
 {
     parent::__construct($id, $module, $config = []);
 }
開發者ID:apanly,項目名稱:dream,代碼行數:4,代碼來源:AuthController.php

示例15: __construct

 public function __construct($id, $module, $config = [])
 {
     parent::__construct($id, $module, $config);
     $this->response = new \stdClass();
     $this->response->data = null;
 }
開發者ID:serj1chen,項目名稱:accident_uawebchallenge,代碼行數:6,代碼來源:BaseController.php


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