App\Proxy\EntityManagerProxy:
decorates: 'doctrine.orm.entity_manager'
services:
App\Mailer: ~
App\DecoratingMailer:
decorates: App\Mailer
# pass the old service as an argument
arguments: ['@.inner']
services:
Doctrine\ORM\EntityManagerInterface: ~
App\Proxy\EntityManagerProxy:
decorates: Doctrine\ORM\EntityManagerInterface
arguments: ['@.inner']
Error: Cannot instantiate interface Doctrine\ORM\EntityManagerInterface
Где у вас декоратор, который будет передаваться в нужный сервис?
Symfony\Component\DependencyInjection\Exception\RuntimeException: Cannot autowire service "Doctrine\ORM\EntityManagerInterface": argument "$entityManager" of method "App\Proxy\EntityManagerProxy::__construct()" references class "Doctrine\ORM\EntityManager" but no such service exists. Try changing the type-hint to "Doctrine\ORM\EntityManagerInterface" instead.
Doctrine\ORM\EntityManagerInterface:
public: true
class: App\Proxy\EntityManagerProxy
Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException: Circular reference detected for service "Doctrine\ORM\EntityManagerInterface", path: "Doctrine\ORM\EntityManagerInterface -> Doctrine\ORM\EntityManagerInterface".
Symfony\Component\DependencyInjection\Exception\RuntimeException: Cannot autowire service "Doctrine\ORM\EntityManagerInterface": argument "$entityManager" of method "App\Proxy\EntityManagerProxy::__construct()" references class "Doctrine\ORM\EntityManager" but no such service exists. Try changing the type-hint to "Doctrine\ORM\EntityManagerInterface" instead.
Просто интересно, для чего тебе это?
class DemoComponent
{
private EntityManagerInterface $em;
/**
* @param EntityManagerInterface $em
*/
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
/**
* @return EntityManagerInterface
*/
public function getEm(): EntityManagerInterface
{
return $this->em;
}
}
Doctrine\ORM\EntityManager:
class: App\Proxy\EntityManagerProxy
App\Components\DemoComponent:
public: true
public function testDoctrine(): void
{
$demo = self::$container->get(DemoComponent::class);
var_dump(get_class($demo->getEm())); // Doctrine\ORM\EntityManager
}
Обновил композер до 2 версии - пакет поставился нормально.