Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.4 and higher |
Works:
services:
App\Repository\UserRepository:
factory: 'Doctrine\ORM\EntityManagerInterface:getRepository'
arguments: [App\Entity\User]
Works:
<?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use App\Entity\User;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
return function (ContainerConfigurator $configurator) {
$configurator
->services()
->set(UserRepository::class)
->factory([ref(EntityManagerInterface::class), 'getRepository'])
->args([
User::class,
]);
};
Doesn't work and says Cannot dump definition because of invalid class name ('Doctrine\\ORM\\EntityManagerInterface:getRepository')
:
<?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use App\Entity\User;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
return function (ContainerConfigurator $configurator) {
$configurator
->services()
->set(UserRepository::class)
->factory(EntityManagerInterface::class.':getRepository')
->args([
User::class,
]);
};