Extending ZfcUsers UserController

烈酒焚心 提交于 2019-12-13 04:18:34

问题


i want to extend the UserController with an setEventManager implementation, to display another layout - just with an login mask.

When i call the url www.example.com i get my Controller, with the other layout. But if type in a wrong username, i redirected to www.exmpale.com/user/login and i get the default layout.

How i can overwrite all routes from ZfcUser Module and redirect them to my own controller, to ensure, the UserController can not called directly.

Thank you.


回答1:


If I understand your question right, you probably just have to edit the file module.config.php. It contains all route definitions.

From how I understand your question you have an own controller called something like MyBetterUserController?

You can add an own module as extension to the ZfcUser module, maybe you want to call it something like ZfcUserMod. This new module will only contain a Module.php file and a folder config with the configuration file.

Then you can define your routes in this module’s configuration file and overwrite all routes from ZfcUser. Make sure that you use the exactly same route names (the keys in the array) as ZfcUser does (currently they use zfcuser as route name). Otherwise the routes will not be overwriten and the UrlHelper will not use your routes.

Then add ZfcUserMod to the global application.config.php after ZfcUser.




回答2:


Wouldn't it be easier to override just the controllers -> invocables pointing 'zfcuser' => 'namespace\your\extendedusercontroller' instead of rewriting all the routes ?



来源:https://stackoverflow.com/questions/14643102/extending-zfcusers-usercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!