Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dot\Frontend\User\Controller\UserController doesn't overwrite Dot\User\Controller\UserController #2

Closed
dantofei opened this issue Jan 17, 2017 · 2 comments

Comments

@dantofei
Copy link

I'm having some issues with the UserController from the main src/ folder

It seems that the UserController from src/Frontend/User/Controller/UserController.php can't overwrite the UserController from vendor/dotkernel/dot-user/src/Controller/UserController.php

@dantofei dantofei changed the title Dot\Frontend\User\Controller\UserController doesn't overwrite Dot\User\Controller\UserControlelr Dot\Frontend\User\Controller\UserController doesn't overwrite Dot\User\Controller\UserController Jan 17, 2017
@n3vrax
Copy link

n3vrax commented Jan 17, 2017

Hi,

I'll check into this, but it would be helpful to include the steps you have taken to overwrite the UserController and the error you get. There are a lot of reasons why it could fail.

As a side note, I'll publish in the future the best ways you can overwrite the UserController. Usually, it will be enough to overwrite UserService or hook into the RegisterEvent::EVENT_REGISTER_PRE event.

The UserController registerAction does nothing more that getting data from POST and validating it with the RegisterForm, than calling the UserService's register method. Given that you can hook into the RegisterForm events, to change form Elements(there is already an example in dot-frontend), or create a delegator factory to further change the RegisterForm creation process, this should be enough to customize the data you send and validate through POST to match you user data structure.

To customize the entire registration process, you can overwrite UserService register method instead, as we don't keep business logic into the controller.

Extending the UserController should be the last thing to consider, but it could be possible.

To summarize

  • all forms used by the dot-user package trigger init events you can listen and further customize them. This helps to adapt the forms to match your user data structures. You can also customize the forms by registering delegator factories for them(see zend-servicemanager documentation)
  • if you need to take custom actions pre/post some user action, you can hook into the triggered events(triggered by the UserService). See user_event_listeners module config key.
  • for maximum flexibility, you could overwrite UserService methods, but keep in mind you should trigger the events by yourself. I would not recommend this solution without understanding how the dot-user module works.

Indeed, this is not very well documented yet, but we'll try to make sure that no matter what method you decide to follow, it won't be a pain.

@n3vrax n3vrax removed the bug label Jan 17, 2017
@n3vrax
Copy link

n3vrax commented Mar 12, 2017

I'll close this, as the frontend was completely updated, the user module and the mapper module were redesigned from ground-up.

As means of extending the user module, I'm pretty certain that user controller can be overwritten and replaced in the routes config, or additional user controllers can be added to the same route key, user service can be overwritten, or the new event system can be used to hook into user events, for additional logic

@n3vrax n3vrax closed this as completed Mar 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants