Skip to content

More flexibility for registration #874

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

Closed
arodiss opened this issue Nov 19, 2012 · 10 comments
Closed

More flexibility for registration #874

arodiss opened this issue Nov 19, 2012 · 10 comments

Comments

@arodiss
Copy link

arodiss commented Nov 19, 2012

While securityController provides a possibility to override template used for login (via renderLogin() method overriding), registrationController does not offer such functionality. The used template is defined in action method itself, and so to override it I have to copy-paste whole method or inherit bundle.
From my POV it would be nice to separate template rendering as it is done in securityController
Thanks.

@stof
Copy link
Member

stof commented Nov 19, 2012

If you only want to overwrite the template, use the template overwriting feature by putting it in app/Resources/FOSUserBundle/views/...

@topwebstudio
Copy link

If you need to override the action, for example you got too much logic to change there go ahead.
If you have only few lines to change why don't you do this:

class RegistrationController extends BaseController {

    public function registerAction() {
                // custom logic - add page title
        $this->addTitle('Registration');

        return BaseController::registerAction();
    }

@tiagojsag
Copy link

I'm stumbled upon a similar problem: in my case, I need to change the behavior of the registration process, not just the looks of it. In my scenario, the user register and gets created as disabled, and an email need to be sent to some admin that will later on approve the account using SonataUserBundle's admin interface.

To do so, it seems like I need to override the registration controller, the form handler, and the user manager (and lets see what else).

It's really nice that we can override the controllers, but in this case it seems pretty useless since a relevant part of the logic is done in the form handler and the user manager, both of which are private services, which makes it even harder to override.

Also, and I didn't research this thoroughly, so pardon me if I'm saying something awfully wrong, but the registration controller and registration form handler seem to be so specific that they can neither be used on their own nor reused for something else.

I have two suggestions: first, don't use private services.
Second: externalize the full registration logic to a separate service, that matches a RegistrationStrategyInterface. Those strategies would be given to the RegistrationController as config parameter. Right now I see two implemented: the default "register and you're done" and "register and get a confirmation email". If these two could be fit into a single file each, it would help people implement their own, without having to reimplement 50 services, and you might even receive some that could be merged into the bundle.

anyway, just my 2 cents.

@stof
Copy link
Member

stof commented Dec 21, 2012

Replacing the form handler is possible through the configuration. And the form handler is a public service. We create an alias of the actual implementation (the default one being private)

And see #867 for the upcoming version of the logic. As you can see, the confirmation email logic is now handled by a dedicated listener. Your logic sending a mail to the admin would simply be a matter of writing your own listener hooking into the events.

@tiagojsag
Copy link

Well, I just finished taking a look at it, and it seems really easy to extend, specially when compared to the previous implementation. congratulations on the excelent job ;)

@ghost
Copy link

ghost commented Jan 20, 2013

@tiagojsag, @arodiss: So any thoughts on this ticket after hearing from Stof? Should any of this be adapted or continued at all?

@vkartaviy
Copy link

Also you might be interested in view events that i provided in pull request #913 but it looks like repository owners not really like contributions from outside or just have no time to review the changes...

@tiagojsag
Copy link

For my implementation it was enough to avoid rewriting a bunch of code that could be reused. I did miss some additional data being passed to some events, but in the end I was able to make it work anyway ;) for me, this can be closed

@ghost
Copy link

ghost commented Jun 23, 2013

@tiagojsag : what information would you like to see added to the events?

@XWB
Copy link
Member

XWB commented Nov 29, 2016

Several events have been added.

@XWB XWB closed this as completed Nov 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants