function DrupalKernel::generateServiceIdHash

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::generateServiceIdHash()

Generate a unique hash for a service object.

Parameters

object $object: A service object.

Return value

string A unique hash value.

Deprecated

in drupal:9.5.1 and is removed from drupal:11.0.0. Use the 'Drupal\Component\DependencyInjection\ReverseContainer' service instead.

See also

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

File

core/lib/Drupal/Core/DrupalKernel.php, line 848

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

public static function generateServiceIdHash($object) {
    @trigger_error(__METHOD__ . "() is deprecated in drupal:9.5.1 and is removed from drupal:11.0.0. Use the 'Drupal\\Component\\DependencyInjection\\ReverseContainer' service instead. See https://www.drupal.org/node/3327942", E_USER_DEPRECATED);
    // Include class name as an additional namespace for the hash since
    // spl_object_hash's return can be recycled. This still is not a 100%
    // guarantee to be unique but makes collisions incredibly difficult and even
    // then the interface would be preserved.
    // @see https://php.net/spl_object_hash#refsect1-function.spl-object-hash-notes
    return hash('sha256', get_class($object) . spl_object_hash($object));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.