Skip to content
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

DependencyInjection not passing service via interface #34361

Closed
michaljusiega opened this issue Nov 13, 2019 · 5 comments · Fixed by #34370
Closed

DependencyInjection not passing service via interface #34361

michaljusiega opened this issue Nov 13, 2019 · 5 comments · Fixed by #34370

Comments

@michaljusiega
Copy link
Contributor

Symfony version(s) affected: 4.4.0-BETA1

Description
In SF 4.3 I adding my custom services like:

    # SERVICES #
    Intranet\Service\:
        resource:      '../../src/Service'
        public:        true
        autowire:      true
        autoconfigure: true

So my all services pathname was a ProjectDir/src/Service. Each service implements custom interface naming like class name of service + 'Interface'. Path of interfaces was ProjectDir/src/Interfaces/Service so namespace looking like: Intranet\Interfaces\Service.

When I passing via DI one service using a interface, in SF 4.3 everything was fine, and i getting a object of passed service.

After update to 4.4 now i'm getting a error from DI like:
Cannot autowire service "Intranet\Controller\AdministracjaController": argument "$parseAddressIPService" of method "__construct()" references interface "Intranet\Interfaces\Service\ParseAddressIPServiceInterface" but no such service exists. You should maybe alias this interface to the existing "Intranet\Service\ParseAddressIPService" service.

Changing to passing directly by service resolve problem, but I don't wanna make this.

@michaljusiega michaljusiega changed the title DependencyInjection not passing interface of service DependencyInjection not passing service via interface Nov 13, 2019
@nicolas-grekas
Copy link
Member

Might be related to changes done in #33350
Can you provide a small reproducer app?

@michaljusiega
Copy link
Contributor Author

@nicolas-grekas I will try.

@michaljusiega
Copy link
Contributor Author

@nicolas-grekas
Copy link
Member

Thanks for the reproducer, it allowed me to spot the issue!

@fabpot fabpot closed this as completed Nov 14, 2019
fabpot added a commit that referenced this issue Nov 14, 2019
…grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[DI] fix detecting singly implemented interfaces

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34361
| License       | MIT
| Doc PR        | -

Commits
-------

eccb937 [DI] fix detecting singly implemented interfaces
@TomasVotruba
Copy link
Contributor

Will this be backported to 4.3? That would be great 👍

That's the minimum version I use now and it would allow me to drop my own compilser pass that adds this feature.

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

Successfully merging a pull request may close this issue.

6 participants