Skip to content

[DependencyInjection] update service_container.rst #17051

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

Conversation

mohamedGasmii
Copy link
Contributor

Add alternative solution.


# If you type-hint SiteUpdateManager
# for a ``$normalUsers`` argument is detected.
App\Service\SiteUpdateManager $normalUsers: '@site_update_manager.normal_users'
Copy link
Contributor

Choose a reason for hiding this comment

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

@nicolas-grekas can you confirm? TBH I never heard/saw such thing.

Should we add it to the docs?

Thanks

Copy link
Member

Choose a reason for hiding this comment

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

yes, it's a named autowiring alias, and it's good to tell about it indeed
that being said, we have the service_container/autowiring.rst that already explains what they are.
I think the example should be removed and replaced by a link to that page.

@OskarStark OskarStark modified the milestones: 4.4, 5.4 Aug 14, 2023
Comment on lines 1195 to +1198
If you want to pass the second, you'll need to :ref:`manually wire the service <services-wire-specific-service>`.

Another solution is to add another id ``site_update_manager.superadmin`` followed by
a variable name matching the one you use when doing the injection::
Copy link
Member

@nicolas-grekas nicolas-grekas Aug 14, 2023

Choose a reason for hiding this comment

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

Suggested change
If you want to pass the second, you'll need to :ref:`manually wire the service <services-wire-specific-service>`.
Another solution is to add another id ``site_update_manager.superadmin`` followed by
a variable name matching the one you use when doing the injection::
If you want to pass ``site_update_manager.superadmin``, you'll need either to :ref:`manually wire it<services-wire-specific-service>`
or to create a named autowiring alias.

(named autowiring alias should link to service_container/autowiring.rst, then, the example is not needed)

OskarStark added a commit to OskarStark/symfony-docs that referenced this pull request Aug 14, 2023
@OskarStark
Copy link
Contributor

Closed via #18749

@OskarStark OskarStark closed this Aug 14, 2023
OskarStark added a commit that referenced this pull request Aug 14, 2023
This PR was merged into the 5.4 branch.

Discussion
----------

[DependencyInjection] Ref for autowiring alias

Replaces
* #17051

I had a lot of conflicts, because #17051 was against `4.4` branch, so I decided to recreate this PR.

Commits
-------

6d0552c Ref for autowiring alias
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.

4 participants