脚本宝典收集整理的这篇文章主要介绍了php – 如何在ZF2中删除路由?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
zfCADmin-route是/ admin. zfcuser路由是/ user. ZfcUserlist-modules附带了zfcuser的子路由,名为zfcuserlist,并指向/ user / list.
而不是/ user / list我想通过/ admin / user调用用户列表.那当然没问题,我刚为zfcadmin注册了一个子路由.
现在我想删除模块附带的用户列表的默认路由.所以我的问题是:如何在ZF2中取消注册/删除某条路线?
为了清理,我有以下路径:
/admin /admin/user <- I added this one /user/list <- This comes shipPEd wITh the ZfcUserlist-module. I want to remove it
有什么建议?
namespace Foo; use Zend\ModuleManager\ModuleEvent; use Zend\ModuleManager\ModuleManager; class Module { public function init(ModuleManager $moduleManager) { $events = $moduleManager->getEventManager(); // Registering a listener at default PRiority,1,which will trigger // after the ConfigListener merges config. $events->attach(ModuleEvent::EVENT_MERGE_CONfig,array($this,'onMergeConfig')); } public function onMergeConfig(ModuleEvent $e) { $configListener = $e->getConfigListener(); $config = $configListener->getMergedConfig(false); // Modify the configuration; here,we'll remove a specific key: if (isset($config['router']['routes']['your_route'])) { unset($config['router']['routes']['your_route']); } // Pass the changed configuration back to the listener: $configListener->setMergedConfig($config); } }
以上是脚本宝典为你收集整理的php – 如何在ZF2中删除路由?全部内容,希望文章能够帮你解决php – 如何在ZF2中删除路由?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。