I need to find a user object in symfony2 based on the username or emailadres. This is not for loggin in, but for other actions on a user.
I can simply request the (Doctrine2) repository and call the method loadByUsername from the UserProviderInterface that is on my repository-class.
But the code that needs to do this will be used in multiple projects and I need it to be a bit more generic. The user class/table might be different or the users might come from a completely different type of provider.
Is there a way to find a user by username just like Symfony2 itself uses when logging in? This way it will work no matter how the user providers are configured in security.yml.
Is there some service in Symfony2 I can use for this? Is there a "user provider service" where I can call a method something like "loadUserByUsername" that will try each configured provider?