Symfony is injecting the wrong class as a dependency

83 Views Asked by At

As I am trying to load the $userManager parameter in the following class:

final class AclUserManager implements AdminAclUserManagerInterface
{
    private $userManager;

    public function __construct(UserManagerInterface $userManager)
    {
        $this->userManager = $userManager;
    }

    public function findUsers(): iterable
    {
        return $this->userManager->findUsers();
    }
}

It gives me the following error:

App\Manager\AclUserManager::__construct(): Argument #1 ($userManager) must be of type App\Repository\UserManagerInterface, Sonata\UserBundle\Entity\UserManager given

This is the dependency injection segment from services.yaml :

    App\Manager\AclUserManager:
        arguments:
            - '@App\Repository\UserManagerInterface'

And this is the class definition:

<?php

namespace App\Repository;
use Sonata\UserBundle\Model\UserManagerInterface as UMI;

interface UserManagerInterface extends UMI
{
    public function findUsers(): ?array;

}
0

There are 0 best solutions below