Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | no |
Symfony version | 3.3 |
If a service is decorated and the decorator doesn't set the autowiring-type
explicitly, then it is judged as ambiguous by the AutowirePass, for example:
class Foo
{
public function __construct(AccessDecisionManagerInterface $accessDecisionManager)
{
}
}
AppBundle\Foo:
autowire: true
Gives:
[Symfony\Component\DependencyInjection\Exception\RuntimeException]
Unable to autowire argument of type "Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface" for the service "AppBundle\Foo".
Multiple services exist for this interface (debug.security.access.decision_manager, debug.se
curity.access.decision_manager.inner).
I think that a nice improvement could be to check that the only 2 alternatives are the decorator and the decorated, and inject the decorator instead of throwing.
I given it a try but calling $this->container->getDefinition('debug.security.access.decision_manager')->getDecoratedService()
from the AutowirePass returns null
since the DecoratorServicePass calls $decorator->setDecoratedService(null);
before that the AutowirePass is called.
Is there something doable in order to make this possible (e.g. changing the AutowirePass priority or avoid calling setDecoratedService(null)
on decorators when processing them)?
If nothing can be done, I'll just propose to fix it for this specific service by adding an autowiring-type
onto.