当前位置: 首页>>代码示例>>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;未经允许,请勿转载。