Skip to content

[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

Closed
wants to merge 1 commit into from

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jan 19, 2015

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Before this commit, parameters in service configuration would not have
been resolved if the new factory syntax (introduced with Symfony 2.6)
were used.

@@ -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);
Copy link
Member

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

Copy link
Member Author

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.
@fabpot
Copy link
Member

fabpot commented Jan 25, 2015

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.

@fabpot
Copy link
Member

fabpot commented Jan 25, 2015

@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.

@xabbuh
Copy link
Member Author

xabbuh commented Jan 25, 2015

@fabpot Indeed, only the factory class could be configured via parameters.

@xabbuh
Copy link
Member Author

xabbuh commented Jan 25, 2015

closing in favor of #13519 and its successor

@xabbuh xabbuh closed this Jan 25, 2015
@xabbuh xabbuh deleted the resolve-factory-parameters branch January 25, 2015 18:12
fabpot added a commit that referenced this pull request Mar 14, 2015
…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
fabpot added a commit that referenced this pull request Mar 17, 2015
…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
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

Successfully merging this pull request may close these issues.

3 participants