-1

I followed the symfony 4 documentation to make a login form (https://symfony.com/doc/current/security/form_login_setup.html) and I added a registration form in the same controller.

I'm a beginner, and I would like to make an account page where the user will be able to change his informations, but I would like to know if I should create a new Controller who work with the user entity, on just work onthe same controller than the login and registration ? Or maybe my user controller have to inherit the securityController?

I'm a noob, sorry ^^'

Thank you

1 Answers1

1

You can give a look at https://symfony.com/doc/current/service_container.html#creating-configuring-services-in-the-container

The path is creating your own service(s), for example App\Servie\UserManager that performs every task on a User object

For example, you could have:

App\Service\UserManager

class UserManager
{
    // ...
    public function handleUpdatePasswordRequest(Request $request) {...}

    // or
    public function handleUpdatePasswordForm(Form $form) {...}

    // or:
    public function handleUpdatePassword(User $user, $newPlainPassword) {...}

    ...
}

as to say, whatever you want to implement, keeping in mind that the thinner the controllers are better it is, while services can grow (and be split) indefinitely

  • Hi, thank you for your help. I made a Service namespace where I put my UserManager. So If I understand, I have to "use" this controller in my security controller where I have my account route ? –  Feb 19 '19 at 12:32
  • you can add a pastebin here, anyway you can do something like https://pastebin.com/sz1SAJzm – Inmarelibero Feb 19 '19 at 13:11
  • It's ok, I understood, I made an accountController with my account's methods. Thank for your help –  Feb 20 '19 at 01:58
  • correct . if you found that useful, consider voting up mu answer :) cheers! – Inmarelibero Feb 20 '19 at 10:01