Skip to content
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

Referencing original arguments in service alteration #154

Open
matej21 opened this issue Jun 26, 2017 · 2 comments
Open

Referencing original arguments in service alteration #154

matej21 opened this issue Jun 26, 2017 · 2 comments

Comments

@matej21
Copy link
Contributor

matej21 commented Jun 26, 2017

  • 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?

@dg
Copy link
Member

dg commented Aug 20, 2017

Or this can keep original arguments:

services:
	application.presenterFactory:
		factory: App\TestPresenterFactory
		alteration: yes

@redwormik
Copy link

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 (

$definition->setCreator(Helpers::filterArguments([$config->create])[0]);
,
$this->creator = $creator instanceof Statement
).

What is the intended (default) behavior – reset or keep?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants