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