Skip to content
Snippets Groups Projects
Commit d57e9fb1 authored by Alexander Schnitzler's avatar Alexander Schnitzler Committed by Susanne Moog
Browse files

[TASK] Mark ObjectManager::get deprecated

This patch adds an @deprecated annotation to the get
method of the ObjectManager class of Extbase. Both the
core and users use the object manager directly to create
instances of dependencies, often like this:

GeneralUtility::makeInstance(ObjectManager::class)
    ->get(Dependency::class);

This is done to create an instance of an object along with
it's own dependencies. Using the object manager directly
is bad practice. Mandatory dependencies should be injected
via constructor injection while optional dependencies may
be injected via method and property injection. In both
cases however, the underlying object container takes care
of the dependency injection.

This patch intentionally does not add a trigger_error call
as the core itself still is a bad example and uses that
technique itself a lot. Version 11.0 will remove all
such usages and introduce the trigger_error call for user
land code until the object manager is finally removed in
version 12.0.

Releases: master
Resolves: #90803
Change-Id: Ie7d678fbb9c3b3041a17a4216f292035cd4c9b30
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63826


Tested-by: default avatarDaniel Goerz <daniel.goerz@posteo.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarSusanne Moog <look@susi.dev>
parent a90718e6
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment