-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add a new Syntax to define factories as callables #12008
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Sep 24, 2014
d2707b6
to
4f7a82f
Compare
if (is_string($factory)) { | ||
$return[] = sprintf('@return object An instance returned by %s().', $factory); | ||
} elseif (is_array($factory) && (is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) { | ||
if (is_string($factory[0] || $factory[0] instanceof Reference)) { |
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.
Typo.
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.
good catch!
👍 |
1 similar comment
👍 |
fabpot
added a commit
that referenced
this pull request
Sep 24, 2014
…ries as callables (realityking, fabpot) This PR was merged into the 2.6-dev branch. Discussion ---------- [DependencyInjection] Add a new Syntax to define factories as callables | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - From the original PR #9839: "This pull requests adds a new syntax to define factories based on the syntax for configurators. This is more flexible than the old syntax (factoryMethod and either of factoryClass or factoryService), as it also allows for functions as factories. Since the service is now a Reference to a Definition it also allows us to inline factories for a small performance improvement and better encapsulation. Lastly this prevents a bug where a private factory is simple removed because it's not referenced in the graph. I did not change any of the existing definitions (there's one use of a factory in FrameworkBundle) or automatically use the new internal representation when parsing YAML or XML definitions because this could introduce subtle B/C issues. " Commits ------- 187aeee fixed CS bd8531d added a new Syntax to define factories as callables.
fabpot
added a commit
that referenced
this pull request
Oct 3, 2014
This PR was merged into the 2.6-dev branch. Discussion ---------- [DependencyInjection] Tweaked factories | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12008 | License | MIT | Doc PR | n/a There are some issues with new service factories: * `ContainerBuilder` cannot instantiate service from factory (i.e. currently it works for dumped code only) * Dumped code sometimes is invalid (anonymous services as factories, factories without arguments) Commits ------- ee82392 [DependencyInjection] Tweaked factories
This was referenced Nov 19, 2014
weaverryan
added a commit
to symfony/symfony-docs
that referenced
this pull request
Nov 24, 2014
This PR was merged into the 2.6 branch. Discussion ---------- Use new factory syntax | Q | A | --- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#12008) | Applies to | 2.6+ | Fixed tickets | #4291 Commits ------- 9cbcc2b Applied fixes d7998b0 Use new factory syntax
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From the original PR #9839:
"This pull requests adds a new syntax to define factories based on the syntax for configurators. This is more flexible than the old syntax (factoryMethod and either of factoryClass or factoryService), as it also allows for functions as factories.
Since the service is now a Reference to a Definition it also allows us to inline factories for a small performance improvement and better encapsulation.
Lastly this prevents a bug where a private factory is simple removed because it's not referenced in the graph.
I did not change any of the existing definitions (there's one use of a factory in FrameworkBundle) or automatically use the new internal representation when parsing YAML or XML definitions because this could introduce subtle B/C issues.
"