You are here

public function Domain::createDomainId in Domain Access 8

Creates a unique domain id for this record.

Overrides DomainInterface::createDomainId

1 call to Domain::createDomainId()
Domain::preSave in domain/src/Entity/Domain.php
Acts on an entity before the presave hook is invoked.

File

domain/src/Entity/Domain.php, line 392

Class

Domain
Defines the domain entity.

Namespace

Drupal\domain\Entity

Code

public function createDomainId() {

  // We cannot reliably use sequences (1, 2, 3) because those can be different
  // across environments. Instead, we use the crc32 hash function to create a
  // unique numeric id for each domain. In some systems (Windows?) we have
  // reports of crc32 returning a negative number. Issue #2794047.
  // If we don't use hash(), then crc32() returns different results for 32-
  // and 64-bit systems. On 32-bit systems, the number returned may also be
  // too large for PHP.
  // See #2908236.
  $id = hash('crc32', $this
    ->id());
  $id = abs(hexdec(substr($id, 0, -2)));
  $this
    ->createNumericId($id);
}