I have a service which requires a closure when trying to setup it using calls: in Symfony DI YAML file.
Illuminate\Queue\QueueManager:
arguments:
app: "@app"
calls:
- [ addConnector, [ "@Illuminate\\Queue\Connector\NullConnector" ]]
I am wondering if I can enclose a service into a closure, as the library code won't let me insert anything else.
public function addConnector($driver, Closure $resolver)
{
$this->connectors[$driver] = $resolver;
}
Is there a way I can create Closure (or, an anonymous function) in Symfony DI container YAML definition file? I guess it could be done with some compiler pass, but I wonder whether there possibly is an existing solution to this problem.
You have probably already solved this by now. But you can create a factory that returns a Closure
some_callback:
public: false
class: callback
factory: [SomeClass\Factory, create]
And you can pass that to the addConnector call:
Illuminate\Queue\QueueManager:
arguments:
app: "@app"
calls:
- [ addConnector, ["@Illuminate\\Queue\Connector\NullConnector", "@some_callback"]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With