当我试图在一个模块中创建到多个控制器的路由时,我得到了this
sorted [] = Both
sorted [_] = Both
sorted (x:y:ys) | x > y = mappend rec Ascending
| x < y = mappend rec Descending
| otherwise = NotSorted
where rec = sorted (y:ys)
致电 'application' => [
'type' => Segment::class,
'options' => [
'route' => '/application[/:action]',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
'vehicles' => [
'type' => Segment::class,
'options' => [
'route' => '/vehicles[/:action]',
'defaults' => [
'controller' => Controller\VehiclesController::class,
'action' => 'index',
],
],
],
的{{1}}完美无缺。但它对indexAction()
不起作用。我试图在IndexController
中调用VehiclesController
- 不成功。
VehiclesController
使用factories
功能
'controllers' => [
'factories' => [
Controller\IndexController::class => InvokableFactory::class,
Controller\VehiclesController::class => InvokableFactory::class,
],
],
答案 0 :(得分:0)
您可能正在执行以下操作来调用key=value
module.config.php
因此,您可能在'controllers' => [
'factories' => [
Controller\IndexController::class => InvokableFactory::class,
Controller\IndexController::class => InvokableFactory::class,
],
],
键下两次使用相同的控制器名称。它可以是上述或不同的方式。
因此,在factories
密钥的factories
子项下定义它们一次,如下所示
controllers