-
-
Notifications
You must be signed in to change notification settings - Fork 75
Description
Currently, it is possible to use setArguments() method of ServiceDefinition to set partial arguments and have the rest autowired:
$builder->addDefinition(...)
->setFactory(...)
->setArguments([
2 => $config['value']
])However, if we want to modify other arguments later, we can't use the same method because it'll throw away anything set previously, ie:
$builder->getDefinition(...)
->setArguments([
3 => $config['another value'] // 2nd argument is now lost.
])I think this behavior may be confusing since method principally does allow to set an incomplete list of arguments.
It is possible to do something like this, but it looks awkward to actually use such construct as the rest of the API is nice and concise:
$builder->getDefinition(...)
->getFactory()
->arguments[3] = $config['another value']; // 2nd argument is now preserved.On the other hand, being able to 'unset' previously set arguments may still be useful, and for that use case setArguments still does the job. Maybe we could have a different method to merge arguments passed into the current list, such as addArguments or mergeArguments? (these two names don't sound perfect though)