У меня есть класс
class ExistsChecker
{
/**
* @var Repository
*/
private $repository;
/**
* @var UniqueEntity
*/
private $uniqueEntity;
public function __construct(
UniqueEntityInterface $uniqueEntity,
Repository $repository
) {
$this->repository = $repository;
$this->uniqueEntity = $uniqueEntity;
}
}
Repository и UniqueEntityInterface - интерфейсы. У репозитория есть 3 реализации, а у UniqueEntityInterface - одна сущность
Я пишу так
user_exists_checker:
class: App\ExistsChecker
arguments:
App\Repository\Repository: '@App\Repository\User\DoctrineUserRepository'
App\Entity\UniqueEntityInterface: '@App\Entity\User'
А на выходе получаю
Cannot autowire service "user_exists_checker": argument "$repository" of method "App\ExistsChecker::__construct()" references interface "App\Repository\Repository" but no such service exists. You should maybe alias this interface to one of these existing services: "App\Repository\DoctrineRepository", "App\Repository\User\DoctrineUserRepository", "App\Repository\Workspace\DoctrineWorkspaceRepository".