gii defaultController.php 怎么运行actionAction 方法 [ 2.0 版本 ]
/**
* Runs an action defined in the generator.
* Given an action named "xyz", the method "actionXyz()" in the generator will be called.
* If the method does not exist, a 400 HTTP exception will be thrown.
* @param string $id the ID of the generator
* @param string $name the action name
* @return mixed the result of the action.
* @throws NotFoundHttpException if the action method does not exist.
*/
public function actionAction($id, $name)
{
$generator = $this->loadGenerator($id);
$method = 'action' . $name;
if (method_exists($generator, $method)) {
return $generator->$method();
}
throw new NotFoundHttpException("Unknown generator action: $name");
}
尝试了好几种方式,都没有走进去,在gii扩展的Module文件看到往UrlManager注册了路由访问规则,
public function bootstrap($app)
{
if ($app instanceof \yii\web\Application) {
$app->getUrlManager()->addRules([
['class' => 'yii\web\UrlRule', 'pattern' => $this->id, 'route' => $this->id . '/default/index'],
['class' => 'yii\web\UrlRule', 'pattern' => $this->id . '/<id:\w+>', 'route' => $this->id . '/default/view'],
['class' => 'yii\web\UrlRule', 'pattern' => $this->id . '/<controller:[\w\-]+>/<action:[\w\-]+>', 'route' => $this->id . '/<controller>/<action>'],
], false);
} elseif ($app instanceof \yii\console\Application) {
$app->controllerMap[$this->id] = [
'class' => 'yii\gii\console\GenerateController',
'generators' => array_merge($this->coreGenerators(), $this->generators),
'module' => $this,
];
}
}
共 0 个回答
没有找到数据。
小叮当的肚兜
注册时间:2016-10-31
最后登录:9小时前
在线时长:97小时45分
最后登录:9小时前
在线时长:97小时45分
- 粉丝13
- 金钱44010
- 威望270
- 积分47680