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


PHP Controller::createAction方法代码示例

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


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

示例1: createAction

 /**
  * Creates an action based on the given action ID.
  * The method first checks if the action ID has been declared in [[actions()]]. If so,
  * it will use the configuration declared there to create the action object.
  * If not, it will look for a controller method whose name is in the format of `actionXyz`
  * where `Xyz` stands for the action ID. If found, an [[InlineAction]] representing that
  * method will be created and returned.
  * @param string $id the action ID.
  * @throws Exception
  * @return \yii\base\Action the newly created action instance. Null if the ID doesn't resolve into any action.
  */
 public function createAction($id)
 {
     $action = parent::createAction($id);
     if (empty($action)) {
         throw new Exception("Method not found", Exception::METHOD_NOT_FOUND);
     }
     $this->prepareActionParams($action);
     return $action;
 }
开发者ID:wowkaster,项目名称:yii2-json-rpc-2.0,代码行数:20,代码来源:Controller.php

示例2: initRequest

 /**
  * Request has to be sent as POST and with Content-type: application/json
  * @throws \yii\web\HttpException
  */
 private function initRequest($id)
 {
     list($contentType) = explode(";", Yii::$app->request->getContentType());
     //cut charset
     $headers = Yii::$app->request->getHeaders();
     if (!empty($id) || !Yii::$app->request->getIsOptions() && null !== $headers->get('Origin') && (!Yii::$app->request->getIsPost() || empty($contentType) || $contentType != "application/json")) {
         throw new HttpException(404, "Page not found");
     }
     //Call beforeActions on modules and controller to run all filters in behaviors() methods
     $action = parent::createAction('');
     // call beforeAction on modules
     foreach ($this->getModules() as $module) {
         if (!$module->beforeAction($action)) {
             break;
         }
     }
     // call beforeAction on controller
     $this->beforeAction($action);
 }
开发者ID:cranetm,项目名称:yii2-json-rpc-2.0,代码行数:23,代码来源:Controller.php

示例3: createAction

 public function createAction($id)
 {
     $config = $this->_internalActions[$id];
     return $config ? Yii::createObject($config, [$id, $this]) : parent::createAction($id);
 }
开发者ID:hiqdev,项目名称:hipanel-core,代码行数:5,代码来源:Controller.php


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