protected DefaultTableMapping::generateFieldTableName(FieldStorageDefinitionInterface $storage_definition, $revision)
Generates a safe and unambiguous field table name.
The method accounts for a maximum table name length of 64 characters, and takes care of disambiguation.
Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The field storage definition.
bool $revision: TRUE for revision table, FALSE otherwise.
Return value
string The final table name.
File
- core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php, line 379
Class
- DefaultTableMapping
- Defines a default table mapping class.
Namespace
Drupal\Core\Entity\Sql
Code
protected function generateFieldTableName(FieldStorageDefinitionInterface $storage_definition, $revision) { $separator = $revision ? '_revision__' : '__'; $table_name = $storage_definition->getTargetEntityTypeId() . $separator . $storage_definition->getName(); // Limit the string to 48 characters, keeping a 16 characters margin for db // prefixes. if (strlen($table_name) > 48) { // Use a shorter separator, a truncated entity_type, and a hash of the // field UUID. $separator = $revision ? '_r__' : '__'; // Truncate to the same length for the current and revision tables. $entity_type = substr($storage_definition->getTargetEntityTypeId(), 0, 34); $field_hash = substr(hash('sha256', $storage_definition->getUniqueStorageIdentifier()), 0, 10); $table_name = $entity_type . $separator . $field_hash; } return $table_name; }
Please login to continue.