Skip to content

ClassResolver and EntityTypeManager now require the service container as a constructor parameter instead of setting it using setContainer() #890

@github-actions

Description

@github-actions

https://www.drupal.org/node/3419963

Introduced in branch/version: 10.3.x / 10.3.0

Symfony\Component\DependencyInjection\ContainerAwareTrait And Symfony\Component\DependencyInjection\ContainerAwareInterface are being deprecated in Symfony 6.4 and removed in 7.0.

Both Drupal\Core\DependencyInjection\ClassResolver and Drupal\Core\Entity\EntityTypeManager depend on retrieving any arbitrary service from the container, so they still need full access to the container.

We now inject the service_container as an argument in their constructor, instead of making them ContainerAware.

Drupal\Core\DependencyInjection\ClassResolver before:

$class_resolver = new ClassResolver();
$class_resolver->setContainer($container);

Drupal\Core\DependencyInjection\ClassResolver after:

$class_resolver = new ClassResolver($container);

Drupal\Core\Entity\EntityTypeManager before:

$entity_type_manager = new EntityTypeManager($namespaces,  $module_handler, $cache, $string_translation, $class_resolver, $entity_last_installed_schema_repository);

Drupal\Core\Entity\EntityTypeManager after:

$entity_type_manager = new EntityTypeManager($namespaces, $module_handler, $cache, $string_translation, $class_resolver, $entity_last_installed_schema_repository, $container);

The setContainer methods in both classes are now deprecated and will be removed from Drupal 11.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy