function SqlContentEntityStorageSchema::getTemporaryTableMappingPrefix

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::getTemporaryTableMappingPrefix()
  2. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::getTemporaryTableMappingPrefix()
  3. 11.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema::getTemporaryTableMappingPrefix()

Gets a string to be used as a prefix for a temporary table mapping object.

@internal

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: An entity type definition.

\Drupal\Core\Field\FieldStorageDefinitionInterface[] $field_storage_definitions: An array of field storage definitions.

string $first_prefix_part: (optional) The first part of the prefix. Defaults to 'tmp_'.

Return value

string A temporary table mapping prefix.

1 call to SqlContentEntityStorageSchema::getTemporaryTableMappingPrefix()
SqlContentEntityStorageSchema::preUpdateEntityTypeSchema in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Allows subscribers to prepare their schema before data copying.

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php, line 677

Class

SqlContentEntityStorageSchema
Defines a schema handler that supports revisionable, translatable entities.

Namespace

Drupal\Core\Entity\Sql

Code

public static function getTemporaryTableMappingPrefix(EntityTypeInterface $entity_type, array $field_storage_definitions, $first_prefix_part = 'tmp_') {
    // Construct a unique prefix based on the contents of the entity type and
    // field storage definitions.
    $prefix_parts[] = spl_object_hash($entity_type);
    foreach ($field_storage_definitions as $storage_definition) {
        $prefix_parts[] = spl_object_hash($storage_definition);
    }
    $prefix_parts[] = \Drupal::time()->getRequestTime();
    $hash = hash('sha256', implode('', $prefix_parts));
    return $first_prefix_part . substr($hash, 0, 6);
}

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