26/06/2018 - SYMFONY
You can use example below to pass argument value to a class method at runtime with service definition in Symfony.
class MyClass
{
...
public function setClientId(?string $clientId = null)
{
....
}
public function setClientSecret(?string $clientSecret = null)
{
...
}
...
}
services:
app.my_class:
class: MyClass
calls:
- [setClientId, ['%env(CLIENT_ID)%']]
- [setClientSecret, ['%env(CLIENT_SECRET)%']]