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

Use Dependency Injection instead of the container #464

Closed
wants to merge 1 commit into from

Conversation

tacman
Copy link
Contributor

@tacman tacman commented Oct 26, 2023

Injecting the container no longer works in Symfony 7, so we should remove this from the documentation.

Injecting the container no longer works in Symfony 7, so we should remove this from the documentation.
Copy link
Collaborator

@garak garak left a comment

Choose a reason for hiding this comment

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

But we still support Symfony 5 and 6 and will probably support them for a couple of years.
Maybe we can just suggest that the container injection is not supported in Symfony 7+

@stof
Copy link
Collaborator

stof commented Oct 26, 2023

This example uses App:Builder:mainMenu as rendering the menu. this won't work when using DI either.
Btw, this way of referencing menus is deprecated.
To use DI, you need to register your menu builder as a service, which is described in another page of the doc.

We should probably revamp the whole documentation to show the best way first (but the actual best way for modern Symfony projects is not yet implemented as I have an idea of using a [AsMenuBuilder] attribute).

@tacman
Copy link
Contributor Author

tacman commented Oct 26, 2023

Is container injection required to use the menu builder? The intent of my change was to remove the way of getting the repository. But if that's not possible using DI, I'll close this.

@tacman tacman closed this Oct 26, 2023
@stof
Copy link
Collaborator

stof commented Oct 26, 2023

The syntax with colon-separated aliases as menu names does not support DI at all.

To use DI, we need to register menu builders in a different way, so it would require changing the doc example entirely.

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

Successfully merging this pull request may close these issues.

3 participants