本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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 = []);
}
示例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
}
示例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);
}
示例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();
}
示例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 = []);
}
示例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);
}
}
示例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 = []);
}
示例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);
}
示例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);
}
示例13: __construct
public function __construct($id, $module, UserValidation $userValidation, $config = [])
{
$this->userValidation = $userValidation;
parent::__construct($id, $module, $config);
}
示例14: __construct
public function __construct($id, $module, $config = [])
{
parent::__construct($id, $module, $config = []);
}
示例15: __construct
public function __construct($id, $module, $config = [])
{
parent::__construct($id, $module, $config);
$this->response = new \stdClass();
$this->response->data = null;
}