0

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.

Acelasi Eu
  • 914
  • 2
  • 9
  • 30
KFO
  • 328
  • 4
  • 15

2 Answers2

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.

aufziehvogel
  • 7,167
  • 5
  • 34
  • 56
  • Yes, you understand my question right. But i tried to avoid changing the original source files of the module (update compatibility) I also tried to overwrite the routes in my own module.config.php. But this changes take no effect. – KFO Feb 04 '13 at 08:01
  • I think I once had a problem with overwriting routes that might help you. You either have to declare it in a module **before** or **afterwards** (don’t know if you can overwrite them or if already defined routes are not overwriten; I think the first defined route is always used). So you could create a module `KFOZfcUser` and set it in your `application.ini.php` directly before (or after) the real `ZfcUser` module. You have to give your new routes the same names as the ones in `ZfcUser` (i.e. `zfcuser` with the child routes `login` etc.). – aufziehvogel Feb 04 '13 at 15:26
  • Thank you. This is the solution. If i load my Module **after** all other Modules, i can overwrite the settings. **application.config.php:** `return array( 'modules' => array( 'ZfcBase', 'ZfcUser', 'BjyAuthorize', 'KFOOnline', ), // ... more settings );` Please write your solution as answer, so i can mark it as solved. – KFO Feb 05 '13 at 07:42
  • I editted it. Does it really have to be after **all** other modules? I assume it’s enough if it’s after the section you want to overwrite? So I wrote it like this. If not, I will rewrite it as "after all other modules". – aufziehvogel Feb 05 '13 at 20:30
  • Its enough, when my Module is direct after the ZfcUser Module. But know i have all modules grouped in extern and own modules and maybe i have to overwrite another Setting - then i can just do it and have not to change the application.config.php again – KFO Feb 06 '13 at 08:15
0

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

Acelasi Eu
  • 914
  • 2
  • 9
  • 30
m1k3lm
  • 66
  • 2