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

Skip to content

[Dependency Injection] Add autowiring types for aliases #19970

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

hason
Copy link
Contributor

@hason hason commented Sep 19, 2016

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

*
* @param string $type
*
* @return Definition The current instance
Copy link
Member

Choose a reason for hiding this comment

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

- @return Definition
+ @return Alias

Same below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@ogizanagi
Copy link
Contributor

ogizanagi commented Sep 19, 2016

Is it a good idea to use aliases for setting the autowiring type ?
I don't really have arguments against, but despite the fact it appears to be convenient, it feels strange to me to rely on aliases to "add something to the original definition". :/

@hason
Copy link
Contributor Author

hason commented Sep 19, 2016

@ogizanagi see #18040 (comment)

@stof
Copy link
Member

stof commented Sep 19, 2016

@hason the idea is to say Use the "router" service when someone wants a UrlGeneratorInterface instead of saying Use the private "router.default" service. This way, the autowired services would benefit from alias replacements

@hason
Copy link
Contributor Author

hason commented Sep 19, 2016

Oh no! This doesn't work. The autowiring types are lost after each change of alias definition.

@nicolas-grekas nicolas-grekas added this to the 3.x milestone Dec 6, 2016
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jan 31, 2017

Did someone try using a ChildDefinition? I guess it doesn't work because it creates another instance.

services:
   foo_type:
       public: false
       parent: foo
       autowiring_types: [ FooInterface ]

fabpot added a commit that referenced this pull request Feb 1, 2017
…icolas-grekas)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Deprecate autowiring-types in favor of aliases

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #21351, #19970, ~~#18040~~, ~~#17783~~
| License       | MIT
| Doc PR        | symfony/symfony-docs#7445

https://github.com/symfony/symfony/pull/21494/files?w=1
This PR deprecates autowiring-types and replaces them by plain aliases.
ping @dunglas @weaverryan

Eg instead of
```xml
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false">
    <autowiring-type>Doctrine\Common\Annotations\Reader</autowiring-type>
</service>
```

just do:
```xml
<service id="annotations.reader" class="Doctrine\Common\Annotations\AnnotationReader" public="false" />
<service id="Doctrine\Common\Annotations\Reader" alias="annotations.reader" public="false" />
```

Commits
-------

b11d391 [DI] Deprecate autowiring-types in favor of aliases
@fabpot fabpot closed this Feb 1, 2017
@nicolas-grekas nicolas-grekas modified the milestones: 3.x, 3.3 Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants