Ralfp
Ralfp

Reputation: 479

How can you override class from Component package?

I am writing app using Symfony 2 and FOSUserBundle. I want to allow multiple users register with same name and use e-mails to identify them. I have edited users manager for this, turning loadUserByUsername into wrapper for findUserByEmail(). This broken TokenBasedRememberMeServices which uses getUsername() to generate remember me token. How can I replace that class with my own to dont force myself into hacking symfony files every time I update FW framework version?

Upvotes: 1

Views: 288

Answers (1)

Ralfp
Ralfp

Reputation: 479

I found a way:

Symfony bundles store class names in their configuration files params. You can simply overwrite those params by adding this line in config.yml:

# Parameters override
parameters:
    security.authentication.rememberme.services.simplehash.class: MyVendor\UserBundle\RememberMe\TokenBasedRememberMeServices

Upvotes: 5

Related Questions