di
di copied to clipboard
Referencing original arguments in service alteration
- bug report? no
- feature request? yes
When you are altering a service you sometimes need to use args of the original service.
An implementation should be quite easy, so a syntax is the only question.
maybe sth like this:
services:
application.presenterFactory:
factory: App\TestPresenterFactory(%self.factory%)
alteration: yes
what do you think? Any better ideas?
Or this can keep original arguments:
services:
application.presenterFactory:
factory: App\TestPresenterFactory
alteration: yes
Or this can keep original arguments:
services: application.presenterFactory: factory: App\TestPresenterFactory alteration: yes
Should this keep the original arguments now?
The docs look like it should – they do not say the arguments are removed, only that they can be removed via reset. (https://doc.nette.org/cs/3.0/di-services#toc-modifikace-sluzeb, https://doc.nette.org/en/3.0/di-services#toc-modification-of-services).
But the code resets the arguments, when new factory/create is specified (https://github.com/nette/di/blob/086748fee8773b4ca5add34952cc54972de60f07/src/DI/Extensions/ServicesExtension.php#L89, https://github.com/nette/di/blob/038da8e9fb5178fae7657c9318c484a1c556ea17/src/DI/Definitions/ServiceDefinition.php#L74).
What is the intended (default) behavior – reset or keep?