zend-framework2 – ZF2 – 覆盖供应商模块ZFcUser的配置
编辑:
我只是自己找到了解决方案. 由于我的ContentManagerController扩展了AbstractRestfulController,它自然没有实现索引操作.因此’defaults’数组中的’action’字段必须被”或null覆盖.然后将按预期调用取决于HTTP请求类型的正确操作.我在哪里? 这是更新的代码.更改 'defaults' => array( 'controller' => 'zfcuser','action' => 'index',), 至 'defaults' => array( 'controller' => 'ContentManagerControllerContentManager','action' => '',// or null ), —原帖— 我试图从自定义模块(ContentManager)module.config.php中覆盖供应商模块(ZFcUser)的路由. ContentManagerController扩展了原始UserController.我不想触摸ZFcUser的module.config.php,因为它可能会在通过composer进行预期更新后导致麻烦.我想严格分离我从原始供应商文件中所做的任何配置. 'route' => '/user', 至 'route' => '/cms', 现在适用,但不是我想要实现的目标. 'defaults' => array( 'controller' => 'zfcuser', 同 'defaults' => array( 'controller' => 'ContentManagerControllerContentManager', 但这给了我404错误. The requested controller was unable to dispatch the request. Controller: ContentManagerControllerContentManager 似乎两个控制器都存在冲突.当我注释掉’defaults’数组时 我已经做了很多研究,但无法弄清楚这里发生了什么. return array( 'controllers' => array( 'invokables' => array( 'ContentManagerControllerContentManager' => 'ContentManagerControllerContentManagerController','router' => array( 'routes' => array( 'zfcuser' => array( 'type' => 'Literal','priority' => 1000,'options' => array( 'route' => '/cms','defaults' => array( 'controller' => 'ContentManagerControllerContentManager','may_terminate' => true,'child_routes' => array( . . . ),); 谢谢你的帮助! 解决方法
作者找到了解决方案,但没有回答问题(他编辑了),我只是将它复制粘贴到答案中.
我只是自己找到了解决方案.由于我的ContentManagerController扩展了AbstractRestfulController,它自然没有实现索引操作.因此’defaults’数组中的’action’字段必须被”或null覆盖.然后将按预期调用取决于HTTP请求类型的正确操作.我在哪里? 这是更新的代码.更改 'defaults' => array( 'controller' => 'zfcuser', (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |