I had the same problem, here is my solution (basically a combination of the first two answers):
Configure the service in config.yml, do not forget the arguments
services:
custom_user_manager:
class: Acme\UserBundle\Model\CustomUserManager
arguments: [@security.encoder_factory, @fos_user.util.username_canonicalizer, @fos_user.util.email_canonicalizer, @fos_user.entity_manager, Acme\UserBundle\Entity\User]
Then connect the service to the FOS user_manager (also in config.yml):
fos_user:
service:
user_manager: custom_user_manager
In the CustomUserManager answer, the build method, e.g. gilden, said:
class CustomUserManager extends UserManager{
public function __construct(EncoderFactoryInterface $encoderFactory, CanonicalizerInterface $usernameCanonicalizer, CanonicalizerInterface $emailCanonicalizer, ObjectManager $om, $class)
{
parent::__construct($encoderFactory, $usernameCanonicalizer, $emailCanonicalizer, $om, $class);
}
}
source
share