Sets the methods to call after service initialization.
public setMethodCalls ( array $calls = [] ) : |
||
$calls | array | An array of method calls |
return | The current instance |
use Symfony\Component\DependencyInjection\Definition; $serviceDefinition = new Definition(MyService::class); $serviceDefinition->setMethodCalls([ ['setDependency', [new Reference('my_dependency_service')]] ]);
$serviceDefinition = new Definition(MyService::class); $serviceDefinition->setMethodCalls([ ['setConfig', ['my_config_key', 'my_config_value']] ]);Here, we define a setConfig method on the MyService class that takes a key and a value as parameters. We set the method call using an array where the first element is the method name and the second element is an array of parameters. In this case, the parameters are the string 'my_config_key' and 'my_config_value'. The setMethodCalls method is part of the Symfony Dependency Injection component.
public setMethodCalls ( array $calls = [] ) : |
||
$calls | array | An array of method calls |
return | The current instance |