By alexpott on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
9.5.x
Introduced in version:
9.5.1
Issue links:
Description:
Drupal 9.5 and 10.0 shipped with functionality to provide a map of object hashes to service IDs as part of \Drupal\Core\DrupalKernel. This has been replaced by the Drupal\Component\DependencyInjection\ReverseContainer service for performance reasons.
Before
$container = \Drupal::getContainer();
$mapping = \Drupal::service('kernel')->getServiceIdMapping();
$service_id = $mapping[$container->generateServiceIdHash($object)] ?? NULL;
After
$service_id = \Drupal::service('Drupal\Component\DependencyInjection\ReverseContainer')->getId($object);
Note this functionality is low level code that is used by the \Drupal\Component\DependencyInjection\DependencySerializationTrait and is not commonly required in custom or contrib code.
Impacts:
Module developers