New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ServiceDefinition::setArguments() to use previously set arguments #171
Comments
Come to think of it, if the use case is to modify an argument (or arguments), a good method would be If the idea sounds okay, I can submit a pull request, please let me know. |
It is intention. Other parameters may be added via autowiring. |
@dg what do you think about my other comment? I agree that changing the behavior of While autowiring is one of the greatest features Nette has, it cannot be the answer for everything. There are at least two use cases when autowiring can't be used:
Acknowledging those use cases, a need for a convenient method to set individual arguments becomes apparent. I think adding a method to |
The key thing is, if you have a real usecase where it would be really handy. |
The 'real' use case is to be able to modify services created by other extensions. I prefer creating a separate extension when the number of required modifications reaches a certain amount (while still being logically related), rather than dumping it all to a config file. Same if I need to extend a 3rd party extension in a considerable way. |
Ok, send PR :-) |
Currently, it is possible to use
setArguments()
method ofServiceDefinition
to set partial arguments and have the rest autowired: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:
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:
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 asaddArguments
ormergeArguments
? (these two names don't sound perfect though)The text was updated successfully, but these errors were encountered: