Closed tacman closed 1 year ago
Ah, yes, this is because under the hood, the invokable command is a ServiceSubscriber which doesn't support the named aliases.
Luckily, Symfony 6.2 makes it possible to create a workaround. Needs some work in this library but this is what should be possible:
public function __invoke(
IO $io,
#[Target('catalogStateMachine')]
WorkflowInterface $stateMachine,
We can possibly always add the target attribute with the name of the parameter so you wouldn't need to add the Target attribute yourself. Not sure if this would have unintended side-effects though.
We can possibly always add the target attribute with the name of the parameter so you wouldn't need to add the Target attribute yourself. Not sure if this would have unintended side-effects though.
Discovered I cannot do this without side effects: https://github.com/symfony/symfony/issues/48555
Unlike other services, injecting a stateMachine during invoke throws an exception:
I wonder if it has to do with the ability to inject a specific service by name, rather than just type. Injecting via the constructor works as expected.