Review main Merged

63826[TASK] Mark ObjectManager::get deprecated

Alexander Schnitzler CR +2 V +2 Normal +174 −0 updated 04/20/20, 11:58

Commit message

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.

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 1

Files 3