问题描述
我想用setEventManager
实现扩展UserController
,以显示另一个布局-仅带有登录掩码.
i want to extend the UserController
with an setEventManager
implementation, to display another layout - just with an login mask.
当我调用网址www.example.com
时,我得到了带有其他布局的控制器.但是,如果输入错误的用户名,我将重定向to www.exmpale.com/user/login
,并获得默认的布局.
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.
我如何覆盖ZfcUser Module
中的所有路由并将它们重定向到我自己的控制器,以确保UserController
不能直接调用.
How i can overwrite all routes from ZfcUser Module
and redirect them to my own controller, to ensure, the UserController
can not called directly.
谢谢.
推荐答案
如果我正确地理解了您的问题,则可能只需要编辑文件module.config.php
.它包含所有路由定义.
If I understand your question right, you probably just have to edit the file module.config.php
. It contains all route definitions.
根据我对您问题的理解,您有一个名为MyBetterUserController
之类的控制器?
From how I understand your question you have an own controller called something like MyBetterUserController
?
您可以将自己的模块作为扩展添加到ZfcUser
模块,也许您想将其称为ZfcUserMod
之类.这个新模块将只包含一个Module.php
文件和一个包含配置文件的文件夹config
.
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.
然后,您可以在此模块的配置文件中定义路由,并覆盖ZfcUser
中的所有路由.确保使用与ZfcUser
完全相同的路由名称(数组中的键)(当前它们使用 zfcuser 作为路由名称).否则,路由将不会被覆盖,并且UrlHelper不会使用您的路由.
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.
然后将ZfcUserMod
添加到全局application.config.php
之后 ZfcUser
.
Then add ZfcUserMod
to the global application.config.php
after ZfcUser
.
这篇关于扩展ZfcUsers UserController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!