Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
github-actions bot opened this issue Oct 20, 2024 · 0 comments
Labels

Comments

@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants