I have problems calling my ImageEncoderService
inside my LdapUserProvider.php
with Symfony2. On the internet, I only find discussions on how to call services inside repositories, controllers, entities, and commands.
Doing this:
class LdapUserProvider implements UserProviderInterface
{
private $ldapManager;
private $bindUsernameBefore;
private $userClass;
private $em;
private $session;
private $imgEncoder;
public function __construct(LdapManagerUserInterface $ldapManager, $bindUsernameBefore = false, $userClass, $em, ImageEncoderService $imgEnconder)
{
$this->session = new Session();
$this->ldapManager = $ldapManager;
$this->bindUsernameBefore = $bindUsernameBefore;
$this->userClass = $userClass;
$this->em = $em;
$this->imgEnconder = $imgEnconder;
}
...
}
Throw this error:
ContextErrorException in LdapUserProvider.php line 58:
Catchable Fatal Error: Argument 5 passed to
Foo\ApiBundle\Provider\LdapUserProvider::__construct()
must be an instance of Foo\ApiBundle\Service\ImageEncoderService,
none given, called in /app/cache/dev/appDevDebugProjectContainer.php
on line 2202 and defined
Is it even possible to inject the service into a custom provider? Or do I need to inject it somewhere else and then use it inside the provider?
The LDAP provider I'm using is this: https://symfony.com/doc/current/security/ldap.html
PS. The service itself works fine in other places of the app, like commands, controllers etc.