Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Doc about autowiring aliases that only bind to a specific argument name #10206

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
nicolas-grekas opened this issue Aug 22, 2018 · 2 comments
Closed

Comments

@nicolas-grekas
Copy link
Member

As described in symfony/symfony#28234
Related to #10023

@weaverryan weaverryan added this to the 4.2 milestone Aug 22, 2018
@weaverryan weaverryan added DependencyInjection Waiting Code Merge Docs for features pending to be merged labels Aug 22, 2018
nicolas-grekas added a commit to symfony/symfony that referenced this issue Aug 24, 2018
…s-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[DI] Allow autowiring by type + parameter name

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#10206

In #27165, we introduced the possibility to bind by type+name:
```yaml
bind:
    Psr\Log\LoggerInterface $myLogger: @monolog.logger.my_logger
```

But we forgot about aliases. For consistency, they could and should allow doing the same. More importantly, this will open up interesting use cases where bundles could provide default values for typed+named arguments (using the new `ContainerBuilder::registerAliasForArgument()` method). E.g:
```yaml
services:
    Psr\Cache\CacheItemPoolInterface $appCacheForecast: @app.cache.forecast
```
Works also for controller actions and service subscribers (using the real service id as the key).

Commits
-------

c0b8f53 [DI] Allow autowiring by type + parameter name
@javiereguiluz javiereguiluz added Missing Documentation and removed Waiting Code Merge Docs for features pending to be merged labels Sep 7, 2018
@tgalopin
Copy link
Contributor

Can be closed, fixed by #11339

@OskarStark
Copy link
Contributor

Looks you are right, thanks @tgalopin.

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

No branches or pull requests

5 participants