Notify downstream users that ContainerAware is going away

Created on 13 March 2024, 10 months ago
Updated 1 April 2024, 9 months ago

Problem/Motivation

We added the following deprecation skips in 📌 Update to Symfony 6.4 Needs work :

# Temporarily for testing Symfony 6.4.
%Since symfony/dependency-injection 6.4: "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" is deprecated, use dependency injection instead.%
%The ".*" class uses "Symfony\\Component\\DependencyInjection\\ContainerAwareTrait" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The ".*" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%
%The ".*" interface extends "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%

The wildcards here mean that downstream users are not notified. We should make these skips specific to Drupal core so that downstream users are notified they are going away. We should make this change in Drupal 10.3 so that users are notified before Drupal 11.

We also have support for ContainerAware in ClassResolver:

    if ($instance instanceof ContainerAwareInterface) {
      $instance->setContainer($this->container);
    }

We should notify users via a new deprecation that this will be removed in Drupal 11.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Users implementing ContainerAwareInterface or using ContainerAwareTrait will have to find alternative solutions - either normal dependency injection, or service collectors or similar if they need access to arbitrary services from the container.

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.3

Component
Base 

Last updated about 4 hours ago

Created by

🇬🇧United Kingdom longwave UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024