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


PHP web\Controller类代码示例

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


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

示例1: beforeAction

 /**
  * @param \yii\base\Action $action
  */
 public function beforeAction($action)
 {
     if ($action->controller->id == 'default') {
         \yii\web\Controller::redirect('/staff/admin');
     }
     return true;
 }
开发者ID:simplator,项目名称:staff,代码行数:10,代码来源:BackendFilter.php

示例2: getActions

 /**
  * Returns all available actions of the specified controller.
  * @param Controller $controller the controller instance
  * @return array all available action IDs.
  */
 public function getActions($controller)
 {
     $actions = array_keys($controller->actions());
     $class = new \ReflectionClass($controller);
     foreach ($class->getMethods() as $method) {
         $name = $method->getName();
         if ($name !== 'actions' && $method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0) {
             $actions[] = Inflector::camel2id(substr($name, 6), '-', true);
         }
     }
     sort($actions);
     return array_unique($actions);
 }
开发者ID:songhongyu,项目名称:datecenter,代码行数:18,代码来源:CommandController.php

示例3: redirectWithMessages

 /**
  * @param $flag
  * @param $successMessage
  * @param $failedMessage
  *
  * @return \yii\web\Response
  */
 protected function redirectWithMessages($flag, $successMessage, $failedMessage)
 {
     if ($flag) {
         Yii::$app->session->setFlash('success', $successMessage);
         return $this->controller->redirect($this->successUrl);
     } else {
         Yii::$app->session->setFlash('warning', $failedMessage);
         return $this->controller->redirect($this->failedUrl);
     }
 }
开发者ID:ufocoder,项目名称:yii2-syncsocial,代码行数:17,代码来源:ActionSynchronize.php

示例4: init

 public function init()
 {
     parent::init();
     $model = new Category();
     $map = ['status' => 1];
     $model->getList($map);
 }
开发者ID:xiaoneng1988,项目名称:learn,代码行数:7,代码来源:BaseController.php

示例5: 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

示例6: actions

 /**
  * @inheritdoc
  */
 public function actions()
 {
     $actions = parent::actions();
     $actions['login'] = ['class' => LoginAction::className(), 'modelClass' => $this->modelClass];
     $actions['logout'] = ['class' => LogoutAction::className()];
     return $actions;
 }
开发者ID:voskobovich,项目名称:yii2-auth-toolkit,代码行数:10,代码来源:AuthController.php

示例7: 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

示例8: 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

示例9: 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

示例10: behaviors

 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['accessControl'] = $this->accessControlBehavior();
     $behaviors['accessControl']['rules'] = array_merge([['allow' => true, 'actions' => ['grid-view-settings', 'route-to-url'], 'roles' => ['@']]], $behaviors['accessControl']['rules']);
     return $behaviors;
 }
开发者ID:omnilight,项目名称:yz2-admin,代码行数:7,代码来源:GeneralController.php

示例11: beforeAction

 /**
  * @inheritdoc
  *
  * @param \yii\base\Action $action
  * @return bool|\yii\web\Response
  * @throws \yii\web\BadRequestHttpException
  */
 public function beforeAction($action)
 {
     if (Yii::$app->user->isGuest) {
         return $this->redirect(['/passport/account/login']);
     }
     return parent::beforeAction($action);
 }
开发者ID:jhliliang,项目名称:dongdong-gym-admin,代码行数:14,代码来源:NeedLoginController.php

示例12: init

 public function init()
 {
     parent::init();
     $n_sr = false;
     $n_ar = false;
     $n_s = false;
     $n_a = false;
     //poka 4to zdes' delaem zada4i controllera no porom nado srochno pereexat'
     if (!Yii::$app->user->isGuest) {
         if (Yii::$app->user->identity->getStageReportNotification()) {
             $n_sr = Yii::$app->user->identity->getStageReportNotification();
         }
         if (Yii::$app->user->identity->getAssignmentReportNotification()) {
             $n_ar = Yii::$app->user->identity->getAssignmentReportNotification();
         }
         if (Yii::$app->user->identity->getStageNotification()) {
             $n_s = Yii::$app->user->identity->getStageNotification();
         }
         if (Yii::$app->user->identity->getAssignmentNotification()) {
             $n_a = Yii::$app->user->identity->getAssignmentNotification();
         }
     }
     Yii::$app->view->params['n_sr'] = $n_sr;
     Yii::$app->view->params['n_ar'] = $n_ar;
     Yii::$app->view->params['n_s'] = $n_s;
     Yii::$app->view->params['n_a'] = $n_a;
 }
开发者ID:Sheriyev,项目名称:G5-CRM,代码行数:27,代码来源:SiteController.php

示例13: render

 /**
  * If we are acting in the module context and the layout is empty we only should renderPartial the content.
  *
  * @param string $view   The name of the view file (e.g. index)
  * @param array  $params The params to assign into the value for key is the variable and value the content.
  *
  * @return string
  */
 public function render($view, $params = [])
 {
     if (!empty($this->module->context) && empty($this->layout)) {
         return $this->renderPartial($view, $params);
     }
     return parent::render($view, $params);
 }
开发者ID:krystian-thiede,项目名称:luya,代码行数:15,代码来源:Controller.php

示例14: beforeAction

 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         $excludeActions = $this->excludeActions();
         if (in_array($action->id, $excludeActions)) {
             return true;
         }
         if ($this->user->isGuest) {
             throw new UnauthorizedHttpException();
         }
         if ($this->id == 'site') {
             return true;
         }
         /* @var $identity \app\models\admin */
         $identity = $this->user->identity;
         if ($identity->admin_role_id == 1) {
             return true;
         }
         $acls = $identity->adminRole->acls;
         $define = static::acls();
         if (isset($acls[$this->id])) {
             foreach ($acls[$this->id] as $rule => $true) {
                 if (isset($define[$rule]) && isset($define[$rule]['actions']) && in_array($action->id, $define[$rule]['actions'])) {
                     return true;
                 }
             }
         }
         throw new ForbiddenHttpException();
     }
     return true;
 }
开发者ID:mole-org,项目名称:yii2-admin,代码行数:34,代码来源:Controller.php

示例15: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (empty($this->modelTitleForms)) {
         $this->modelTitleForms = PhpMorphy::getNeededForms($this->modelTitle);
     }
 }
开发者ID:e96,项目名称:yii2-madmin,代码行数:10,代码来源:MAdminController.php


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