Skip to content

[DependencyInjection] Defaults are not used for ContainerInterface controller argument #48192

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
lyrixx opened this issue Nov 10, 2022 · 1 comment

Comments

@lyrixx
Copy link
Member

lyrixx commented Nov 10, 2022

Symfony version(s) affected

many

Description

With this configuration:

services:
    _defaults:
        autowire: true
        autoconfigure: true
        bind:
            Psr\Container\ContainerInterface $workflowsLocator2: !tagged_locator { tag: workflow, index_by: name }

and this controller:

    public function debug(ContainerInterface $workflowsLocator2)
    {
        dd([
            'workflowsLocator2' => $workflowsLocator2,
        ]);
    }

I expect to have all workflows, but it's not the case.

Fun fact

  1. it works with iterator
  2. but not locator
  3. if I use a constructor, it's OK
@MatTheCat
Copy link
Contributor

MatTheCat commented Nov 15, 2022

If a binding is only used through controller.service_arguments it never has the chance to reach the ServiceLocatorTagPass, so a ServiceLocatorArgument’s values are not fetched from its iterator 🤔

@fabpot fabpot closed this as completed Nov 22, 2022
fabpot added a commit that referenced this issue Nov 22, 2022
…agPass` (MatTheCat)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] Process bindings in `ServiceLocatorTagPass`

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

Commits
-------

81d0858 [DependencyInjection] Process bindings in ServiceLocatorTagPass
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

4 participants