Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DependencyInjection] Docs for method autowiring#7041

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
dunglas wants to merge2 commits intosymfony:masterfromdunglas:pr_20167

Conversation

@dunglas
Copy link
Member

the service. Constructor injection should always be preferred; however, it is sometimes
convenient to inject dependencies through methods (usually a setter method).

..versionadded::2.8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should be 3.2

$container->setDefinition('foo', $fooDefinition);
Alternatively, the list of method to use for dependency injection can be configured explicitly:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

methods

..code-block::php
use Symfony\Component\DependencyInjection\Reference;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is not used.

@wouterjwouterj added this to the3.3 milestoneNov 9, 2016
fabpot added a commit to symfony/symfony that referenced this pull requestDec 13, 2016
…configurable (dunglas)This PR was merged into the 3.3-dev branch.Discussion----------[DependencyInjection] Make method (setter) autowiring configurable| Q | A || --- | --- || Branch? | master || Bug fix? | no || New feature? | yes || BC breaks? | no || Deprecations? | maybe? || Tests pass? | yes || Fixed tickets |#19631 || License | MIT || Doc PR |symfony/symfony-docs#7041 |Follow up of#19631. Implements#19631 (comment):Edit: the last supported format:``` yamlservices:    foo:        class: Foo        autowire: ['__construct', 'set*'] # Autowire constructor and all setters        autowire: true # Converted by loaders in `autowire: ['__construct']` for BC        autowire: ['foo', 'bar'] # Autowire only `foo` and `bar` methods```Outdated:``` yamlautowire: true # constructor autowiringautowire: [__construct, setFoo, setBar] # autowire whitelisted methods onlyautowire: '*' # autowire constructor + every setters (following existing rules for setters autowiring)```- [x] Allow to specify the list of methods in the XML loader- [x] Add tests for the YAML loaderCommits-------6dd53c7 [DependencyInjection] Introduce method injection for autowiring
symfony-splitter pushed a commit to symfony/dependency-injection that referenced this pull requestDec 13, 2016
…configurable (dunglas)This PR was merged into the 3.3-dev branch.Discussion----------[DependencyInjection] Make method (setter) autowiring configurable| Q | A || --- | --- || Branch? | master || Bug fix? | no || New feature? | yes || BC breaks? | no || Deprecations? | maybe? || Tests pass? | yes || Fixed tickets | #19631 || License | MIT || Doc PR |symfony/symfony-docs#7041 |Follow up of #19631. Implementssymfony/symfony#19631 (comment):Edit: the last supported format:``` yamlservices:    foo:        class: Foo        autowire: ['__construct', 'set*'] # Autowire constructor and all setters        autowire: true # Converted by loaders in `autowire: ['__construct']` for BC        autowire: ['foo', 'bar'] # Autowire only `foo` and `bar` methods```Outdated:``` yamlautowire: true # constructor autowiringautowire: [__construct, setFoo, setBar] # autowire whitelisted methods onlyautowire: '*' # autowire constructor + every setters (following existing rules for setters autowiring)```- [x] Allow to specify the list of methods in the XML loader- [x] Add tests for the YAML loaderCommits-------6dd53c7 [DependencyInjection] Introduce method injection for autowiring
@weaverryan
Copy link
Member

This has now totally been changed -#7608 is the way to do it, which is much simpler. So let's make a PR for that! :)

weaverryan added a commit that referenced this pull requestMay 5, 2017
This PR was merged into the master branch.Discussion----------Updates to DI config for 3.3Hi guys!WIP changes the new DI changes in 3.3! Woohoo! Some notes for myself:This relates to, oh, just these 10+ issues :). Assume they will all be closed by this one PR - before merge, if any of them aren't covered, I'll remove them.TODOS later (some might already be done)- update to use `debug:container --types` (symfony/symfony#22624)- update all other documents for possible changes for autowiring and autoconfigure- new page for existing Symfony users to explain the changes- update autowire section to talk about using aliases- document instanceof and also the ability to add configuration to the PSR4 loader- some links in the controller go to the API docs of `Controller`. But this is wrong, the methodsnow live in `ControllerTrait`... but the API docs for traits is basically broken:http://api.symfony.com/master/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.html- how should we pass a parameter to a controller?- do Twig extensions still need to be public? If so, the example in `service_container` about autoconfigure is still not quite rightDefinitely included in this PR*#7544*#7482*#7339*#7672Not included in this PR (but related to DI changes)*#7329*#7782*#7777*#7706*#7608*#7538*#7441*#7255* ~~#7041~~* ~~#7445~~* ~~#7444~~* ~~#7436~~Commits-------22adfbd removing duplicate target12c4944 Tweaks after amazing review from@GuilhemN and@xabbuhcac3c6c Merge remote-tracking branch 'origin/master' into di-3.3-changes2229fd3 Merge remote-tracking branch 'origin/master' into di-3.3-changes5452c61 Adding section about public: falseee27765 Adding versionaddedbc7088d Merge remote-tracking branch 'origin/di-3.3-changes' into di-3.3-changes443aec2 Merge pull request#7857 from GuilhemN/patch-189e12de bad link6de83e2 fixing build problem759e9b2 last tweaks from feedback45500b3 Adding details and usages of fetching the service as a controller arg70178d1 adding note about autoconfigure6e6ed94 more tweaks0e48bd8 [WIP] Updates to DI config for 3.39ab27f0 Add xml files2636bea bad linkc45daf4 fixing build problem9e84572 last tweaks from feedback049df7d Adding details and usages of fetching the service as a controller arg105801c adding note about autoconfigure2d11347 more tweaks8433fc1 [WIP] Updates to DI config for 3.3
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@snoek09snoek09snoek09 left review comments

@mickaelandrieumickaelandrieumickaelandrieu approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

7 participants

@dunglas@weaverryan@snoek09@mickaelandrieu@javiereguiluz@wouterj@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp