[英]How to set a default action for SocialEngine module
I have created a module with two controllers: Index and Pay. 我创建了一个带有两个控制器的模块:索引和支付。 There are actions for both controllers, ie
两个控制器都有动作,即
Index -> indexAction 索引-> indexAction
Pay -> indexAction, callbackAction, etc. 支付-> indexAction,callbackAction等
I have defined routes in the module's manifest.php, although it seems defining the routes in that file makes no difference as those routes work correctly anyway. 我已经在模块的manifest.php中定义了路由,尽管在该文件中定义路由似乎没有什么区别,因为这些路由无论如何都能正常工作。 The problem is when I browse the root of the module ie http://example.com/pgateway , only a specific action from my second controller (PayController->callbackAction) is executed.
问题是当我浏览模块的根目录(即http://example.com/pgateway)时 ,仅执行第二个控制器中的特定操作(PayController-> callbackAction)。 Why is that and how can I make say IndexController->indexAction the default page when example.com/pgateway is browsed?
为什么会这样?浏览example.com/pgateway时,如何使IndexController-> indexAction成为默认页面?
My route definitions (manifest.php): 我的路线定义(manifest.php):
'routes' => [
'pay_general' => [
'route' => 'pgateway/:controller/:action/*',
'defaults' => [
'module' => 'pgateway',
'controller' => 'pay',
'action' => 'index',
],
'reqs' => [
'controller' => '\D+',
'action' => '\D+',
],
],
'pay_callback' => [
'route' => 'pgateway/:controller/:action/*',
'defaults' => [
'module' => 'pgateway',
'controller' => 'pay',
'action' => 'callback',
],
'reqs' => [
'controller' => '\D+',
'action' => '\D+',
],
],
],
route should be unique, in each definition. 在每个定义中,路线应该是唯一的。
:action
means it would work with values as well as empty. :action
表示它既可以使用值也可以使用空值。 Incase of empty it will use defaults. 如果为空,将使用默认值。 In your case latest route is overriding.
就您而言,最新路线是最重要的。
Try removing pay_callback
, it would work as in pay_general
. 尝试删除
pay_callback
,它将像pay_general
工作。
Convention is manage one route for a controller, and manage accordingly. 惯例是为控制器管理一条路线,并据此进行管理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.