Zend framework2 ZF2-覆盖供应商模块ZFcUser的配置

Zend framework2 ZF2-覆盖供应商模块ZFcUser的配置,zend-framework2,zfcuser,Zend Framework2,Zfcuser,编辑: 我只是自己找到了解决办法。 当我的ContentManagerController扩展AbstractRestfulController时,它自然没有实现索引操作。因此,“defaults”数组中的“action”字段必须被“”或null覆盖。然后,将根据HTTP请求类型按预期调用适当的操作。我的心在哪里 这是更新后的代码。改变 'defaults' => array( 'controller' => 'zfcuser', 'action' =>

编辑: 我只是自己找到了解决办法。 当我的ContentManagerController扩展AbstractRestfulController时,它自然没有实现索引操作。因此,“defaults”数组中的“action”字段必须被“”或null覆盖。然后,将根据HTTP请求类型按预期调用适当的操作。我的心在哪里

这是更新后的代码。改变

'defaults' => array(
    'controller' => 'zfcuser',
    'action'     => 'index',
),
'defaults' => array(
    'controller' => 'zfcuser',
    'action'     => 'index',
),

---原职---

我试图从自定义模块的(ContentManager)module.config.php中重写供应商模块()的路由。ContentManagerController扩展了原始UserController。我不想碰ZFcUser的module.config.php,因为它可能会在通过composer进行预期更新后导致麻烦。我想严格地将我所做的任何配置与原始供应商文件分开。 简单覆盖

'route' => '/user',

现在还可以,但这不是我想要的。 因此,我还需要替换控制器条目

'defaults' => array(
    'controller' => 'zfcuser',
    'action'     => 'index',
),

但这给了我一个404错误

The requested controller was unable to dispatch the request.

Controller:
ContentManager\Controller\ContentManager
似乎两个控制器都有冲突。当我在中注释掉“defaults”数组时 然后按预期调用ZFcUser module.config.php my ContentManagerController。 我还确保我的模块在ZFcUser之后注册。所以重写应该是可行的,好吧

我已经做了很多研究,但不知道这里发生了什么。 所描述的策略不起作用

return array(
    'controllers' => array(
        'invokables' => array(
            'ContentManager\Controller\ContentManager' => 'ContentManager\Controller\ContentManagerController',
        ),
    ),
    'router' => array(
        'routes' => array(
            'zfcuser' => array(
                'type' => 'Literal',
                'priority' => 1000,
                'options' => array(
                    'route' => '/cms',
                    'defaults' => array(
                        'controller' => 'ContentManager\Controller\ContentManager',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    .
                    .
                    .
                ),
            ),
        ),
    ),
);

谢谢你的帮助

作者找到了答案,但没有回答问题(他编辑了它),我只是复制粘贴到答案上。

我只是自己找到了解决办法。当我的ContentManagerController扩展AbstractRestfulController时,它自然没有实现索引操作。因此,“defaults”数组中的“action”字段必须被“”或null覆盖。然后,将根据HTTP请求类型按预期调用适当的操作。我的心在哪里

这是更新后的代码。改变

'defaults' => array(
    'controller' => 'zfcuser',
    'action'     => 'index',
),
'defaults' => array(
    'controller' => 'zfcuser',
    'action'     => 'index',
),

'defaults' => array(
    'controller' => 'zfcuser',
    'action'     => 'index',
),
'defaults' => array(
    'controller' => 'ContentManager\Controller\ContentManager',
    'action'     => '', // or null
),