Mark Drupal::getContainer() as internal

Created on 9 August 2013, over 11 years ago
Updated 22 May 2023, over 1 year ago

Problem/Motivation

Using Drupal::getContainer() is not advisable.

There are valid usecases for Drupal::getContainer() for example in tests, but there should be a message to indicate the narrow use-cases for the method.

Proposed resolution

Let's mark the method as internal and add a message indicating what modules should use instead.

Remaining tasks

Address berdir #28
Change record

User interface changes

None

API changes

Make Drupal::getContainer() internal.

Data model changes

None

Release notes snippet

Original report by [dawehner]

Problem/Motivation

Currently Drupal::getContainer() is marked as deprecated.

There are valid usecases for Drupal::getContainer() for example if you want to inject the container into something else.

Proposed resolution

Let's remove the @deprecated but tell people that it should be avoided and what they should do otherwise.

📌 Task
Status

Needs work

Version

10.1

Component
Base 

Last updated about 13 hours ago

Created by

🇩🇪Germany dawehner

Live updates comments and jobs are added and updated live.
  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024