Navigation Menu

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

[FrameworkBundle] Deprecate AbstractController::get() and has() #42442

Merged
merged 1 commit into from Aug 9, 2021

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Aug 9, 2021

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? yes
Tickets n/a
License MIT
Doc PR n/a

Controllers extending AbstractController have access to the services registered for the shortcuts defined in AbstractController via get() and has(). These methods can make developers think that they have access to the whole container, which is not true. Moreover, the limited set of services are precisely the ones needed for the shortcuts, so probably not the ones people would need anyway.

I propose to deprecate these methods and advocate using method/constructor injection instead.

If people want to still use the container, they can access it via the $this->container property (useful if they extend getSubscribedServices() for instance).

@fabpot fabpot force-pushed the abstract-controller-get-has-deprecation branch from 762cfc1 to eb14ee5 Compare August 9, 2021 08:45
@fabpot fabpot force-pushed the abstract-controller-get-has-deprecation branch from eb14ee5 to f4ee152 Compare August 9, 2021 08:46
@fabpot fabpot force-pushed the abstract-controller-get-has-deprecation branch from f4ee152 to 66a81ea Compare August 9, 2021 09:01
@fabpot fabpot merged commit 8ac480a into symfony:5.4 Aug 9, 2021
@fabpot fabpot deleted the abstract-controller-get-has-deprecation branch August 9, 2021 10:21
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.

None yet

6 participants