-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] resolve parameters in inlined factories on compile #13455
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
Conversation
@@ -1342,11 +1346,13 @@ private function dumpValue($value, $interpolate = true) | |||
} elseif ($value instanceof Variable) { | |||
return '$'.$value; | |||
} elseif ($value instanceof Reference) { | |||
if (null !== $this->referenceVariables && isset($this->referenceVariables[$id = (string) $value])) { | |||
$id = substr($this->dumpValue((string) $value), 1, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ? References cannot use parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for the hint. I reverted this.
Before this commit, parameters in service configuration would not have been resolved if the new factory syntax (introduced with Symfony 2.6) were used.
3db6416
to
6526dfb
Compare
I've investigated this issue further and came up with #13519 which fixes inconsistencies in the "old" way of defining factories (PR for 2.3). When my PR is merged, I will create another on for the new way. |
@xabbuh Can you elaborate a bit more about factory methods. As far as I know, the old way of defining factories and also the new way do not support using a parameter for the method. |
@fabpot Indeed, only the factory class could be configured via parameters. |
closing in favor of #13519 and its successor |
…es (fabpot) This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] fixed service resolution for factories | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13455 | License | MIT | Doc PR | n/a In the service container, factories can be defined with a class/method pair or a service/method pair. The class or service value can be a container parameter, but it was not supported everywhere, this PR fixes that. Note that the method can never be a container parameter as this is supported nowhere in the current code, so this has not been changed. Another PR will fix the 2.6 way of configuring a factory. Commits ------- f86ad95 [DependencyInjection] fixed service resolution for factories
…factories (xabbuh) This PR was merged into the 2.6 branch. Discussion ---------- [DependencyInjection] resolve class parameters in service factories | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This is based on the parameter resolving for factories from #13519 and makes the necessary changes for the new factory syntax introduced in Symfony 2.6. @fabian In #13519, you also updated the `PhpDumper` to make use of `dumpValue()`. Should I do the same here (or in this case reopen #13455)? Commits ------- 8bda37c resolve class parameters in service factories
Before this commit, parameters in service configuration would not have
been resolved if the new factory syntax (introduced with Symfony 2.6)
were used.