当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::beforeAction方法代码示例

本文整理汇总了PHP中yii\web\Controller::beforeAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::beforeAction方法的具体用法?PHP Controller::beforeAction怎么用?PHP Controller::beforeAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\web\Controller的用法示例。


在下文中一共展示了Controller::beforeAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeAction

 public function beforeAction($action)
 {
     if ($action->id == 'index' && Yii::$app->request->referrer !== null) {
         Yii::$app->session->set('returnUrl', Yii::$app->request->referrer);
     }
     return parent::beforeAction($action);
 }
开发者ID:sankam-nikolya,项目名称:yii2-users,代码行数:7,代码来源:AuthController.php

示例2: beforeAction

 public function beforeAction($action)
 {
     if ($action->id === 'result' || $action->id === 'success' || $action->id === 'fail') {
         $this->enableCsrfValidation = false;
     }
     return parent::beforeAction($action);
 }
开发者ID:anderpo,项目名称:7hours.yii.loc,代码行数:7,代码来源:OrdersController.php

示例3: beforeAction

 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (Yii::$app->user->isGuest) {
         return false;
     }
     return parent::beforeAction($action);
 }
开发者ID:jhliliang,项目名称:dongdong-gym-admin,代码行数:10,代码来源:AjaxNeedLoginController.php

示例4: beforeAction

 public function beforeAction($action)
 {
     if (in_array($action->id, $this->needAuthActions)) {
         $this->layout = 'controlpanel';
     }
     return parent::beforeAction($action);
 }
开发者ID:kintastish,项目名称:mobil_old,代码行数:7,代码来源:MController.php

示例5: beforeAction

 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     //Allow access when srbac is in debug mode
     if (!\Yii::$app->getModule('rbac')->rbacCheck) {
         return true;
     }
     // 先判断是否为module
     $mod = $this->module !== null && $this->module->id != \Yii::$app->id ? $this->module->id . $this->delimeter : "";
     $access = $mod . ucfirst($this->id) . $this->action->id;
     // 先检查配置文件中的始终允许(modules配置中的$allowed),再检查数据库设置中的始终允许
     $alwaysAllowed = \Yii::$app->getModule('rbac')->allowed;
     if ($alwaysAllowed) {
         if (in_array(strtolower($access), $alwaysAllowed)) {
             return true;
         }
     }
     // 检查数据库中存储的始终允许
     $allowed = $this->allowedAccess();
     if (array_key_exists($access, $allowed)) {
         return true;
     }
     // Check for rbac access in RBAC Modules Components/SDbAuthManager
     if (\Yii::$app->user->getIsGuest() || !\Yii::$app->authManager->checkAccess($access)) {
         return $this->onUnauthorizedAccess();
     } else {
         return true;
     }
 }
开发者ID:xupengli,项目名称:bmprbac,代码行数:31,代码来源:RbacBaseController.php

示例6: beforeAction

 public function beforeAction($action)
 {
     $config = [];
     switch ($action->id) {
         case 'quiz':
             $config = ['steps' => ['question'], 'timeout' => 30, 'forwardOnly' => true, 'events' => [WizardBehavior::EVENT_WIZARD_STEP => [$this, $action->id . 'WizardStep'], WizardBehavior::EVENT_AFTER_WIZARD => [$this, $action->id . 'AfterWizard'], WizardBehavior::EVENT_STEP_EXPIRED => [$this, $action->id . 'StepExpired']]];
             break;
         case 'registration':
             $config = ['steps' => ['profile', 'address', 'phoneNumber', 'user'], 'events' => [WizardBehavior::EVENT_WIZARD_STEP => [$this, $action->id . 'WizardStep'], WizardBehavior::EVENT_AFTER_WIZARD => [$this, $action->id . 'AfterWizard'], WizardBehavior::EVENT_INVALID_STEP => [$this, 'invalidStep']]];
             break;
         case 'survey':
             $config = ['steps' => ['havePet', ['hasPet' => ['type', ['cat' => ['cat'], 'dog' => ['dog'], 'pet' => ['pet']]], 'noPet' => ['getPet', ['willGet' => ['get']]]]], 'autoAdvance' => false, 'defaultBranch' => false, 'events' => [WizardBehavior::EVENT_WIZARD_STEP => [$this, $action->id . 'WizardStep'], WizardBehavior::EVENT_AFTER_WIZARD => [$this, $action->id . 'AfterWizard'], WizardBehavior::EVENT_INVALID_STEP => [$this, 'invalidStep']]];
             break;
         case 'resume':
             $config = ['steps' => []];
             // force attachment of WizardBehavior
         // force attachment of WizardBehavior
         default:
             break;
     }
     if (!empty($config)) {
         $config['class'] = WizardBehavior::className();
         $this->attachBehavior('wizard', $config);
     }
     return parent::beforeAction($action);
 }
开发者ID:cjq,项目名称:yii2-playground,代码行数:26,代码来源:WizardController.php

示例7: beforeAction

 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         return true;
     }
     return false;
 }
开发者ID:mrbighokage,项目名称:book-test-yii2,代码行数:7,代码来源:AppController.php

示例8: beforeAction

 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $request = Yii::$app->getRequest();
         $response = Yii::$app->getResponse();
         //is this a set-language post request?
         if ($request->isPost && null !== ($language = $request->get('set-language'))) {
             $languages = Yii::$app->params['languages'];
             if (isset($languages[$language])) {
                 $response->cookies->add(new \yii\web\Cookie(['name' => 'language', 'value' => $language]));
             }
             $response->refresh();
             return false;
         }
         //else, read language cookie
         $cookies = $request->cookies;
         if (!empty($cookies['language'])) {
             Yii::$app->language = $cookies['language']->value;
         }
         //page size request?
         $pageSize = filter_input(INPUT_GET, 'page_size', FILTER_VALIDATE_INT);
         if ($pageSize && in_array($pageSize, Yii::$app->params['admin.page.sizes'])) {
             Yii::$app->session->set('admin.page.size', $pageSize);
             unset($_GET['page_size']);
         }
         return true;
     }
     return false;
 }
开发者ID:guillemc,项目名称:yii2starter,代码行数:29,代码来源:BaseController.php

示例9: beforeAction

 public function beforeAction($action)
 {
     if (Yii::$app->request->enableSslRoutes) {
         /**
          * This piece of code here is to allow partial SSL for the minute while we cannot fully use SSL all over the site
          */
         $found = false;
         foreach (Yii::$app->request->sslRoutes as $route) {
             if ($route == Yii::$app->controller->id . '/' . Yii::$app->controller->action->id) {
                 $found = true;
                 if (!Yii::$app->request->getIsSecureConnection() && !isset(error_get_last()['type'])) {
                     $sslUrl = Yii::$app->getUrlManager()->createAbsoluteUrl(Yii::$app->request->absoluteUrl, 'https');
                     return Yii::$app->controller->redirect($sslUrl)->send();
                 }
             }
         }
         if (Yii::$app->request->getIsSecureConnection() && !$found && Yii::$app->controller->id . '/' . Yii::$app->controller->action->id !== 'site/error') {
             $httpUrl = Yii::$app->getUrlManager()->createAbsoluteUrl(Yii::$app->request->absoluteUrl, 'http');
             return Yii::$app->controller->redirect($httpUrl)->send();
         }
     }
     if (Yii::$app->user->enableTier2 && !Yii::$app->user->getIsGuest() && Yii::$app->session->get('tier2Timeout') > time()) {
         Yii::$app->session->set('tier2Timeout', Yii::$app->user->tier2Timeout);
     }
     return parent::beforeAction($action);
 }
开发者ID:sammaye,项目名称:yii2-advanced-template,代码行数:26,代码来源:Controller.php

示例10: beforeAction

 public function beforeAction($action)
 {
     if (Yii::$app->user->isGuest && $this->route != 'site/login') {
         $this->redirect(['/site/login']);
     }
     if ($this->module->id == 'main' && Yii::$app->session['api_url'] == NULL) {
         $this->redirect(['/site/index']);
     }
     $this->authRoute();
     $menus = Yii::$app->params['menu'];
     if ($this->app_code != null) {
         $tools = (require Yii::getAlias('@backend/config/app/' . $this->app_code . '.php'));
         if (!$tools) {
             throw new InvalidConfigException('Loss your app config');
         }
         array_splice($menus, 1, 0, $tools);
     }
     $activeTag = '';
     $menus = $this->normalizeMenu($menus, $activeTag);
     if (isset($menus[$activeTag]['items'])) {
         $this->leftMenu = $menus[$activeTag]['items'];
     } else {
         $this->leftMenu = [];
     }
     foreach ($menus as $key => $items) {
         unset($menus[$key]['items']);
     }
     $this->topMenu = $menus;
     return parent::beforeAction($action);
 }
开发者ID:xuguoliangjj,项目名称:datacenter,代码行数:30,代码来源:BaseController.php

示例11: beforeAction

 /**
  * beforeAction function.
  *
  * @access public
  * @param mixed $action
  * @return void
  */
 public function beforeAction($action)
 {
     $result = parent::beforeAction($action);
     $options = ['tinymce' => \Yii::$app->urlManager->createUrl('/filemanager/files/tinymce'), 'properties' => \Yii::$app->urlManager->createUrl('/filemanager/files/properties')];
     $this->getView()->registerJs("filemanager.init(" . json_encode($options) . ");", \yii\web\View::POS_END, 'my-options');
     return $result;
 }
开发者ID:linchpinstudios,项目名称:yii2-filemanager,代码行数:14,代码来源:FilesController.php

示例12: beforeAction

 public function beforeAction($action)
 {
     if ($this->action->id == 'pay-out') {
         $this->enableCsrfValidation = false;
     }
     return parent::beforeAction($action);
 }
开发者ID:HejVkt,项目名称:auto.only3.ru,代码行数:7,代码来源:PaymentsController.php

示例13: beforeAction

 public function beforeAction($action)
 {
     if ($action->id == 'error') {
         $this->layout = 'main.php';
     }
     return parent::beforeAction($action);
 }
开发者ID:aivavic,项目名称:qreachers,代码行数:7,代码来源:SiteController.php

示例14: beforeAction

 public function beforeAction($action)
 {
     if (\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     return parent::beforeAction($action);
 }
开发者ID:bxgsmart,项目名称:korsun-yii2-web-monitoring,代码行数:7,代码来源:DeviceEventCodeTxtController.php

示例15: beforeAction

 /**
  * @inheritDoc
  */
 public function beforeAction($action)
 {
     if ($action->id == 'crop-avatar') {
         $this->enableCsrfValidation = false;
     }
     return parent::beforeAction($action);
 }
开发者ID:tqsq2005,项目名称:Yii2adv,代码行数:10,代码来源:PersonalController.php


注:本文中的yii\web\Controller::beforeAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。