You are here

public function DefaultTableMapping::getFieldColumnName in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php \Drupal\Core\Entity\Sql\DefaultTableMapping::getFieldColumnName()

Generates a column name for a field property.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The field storage definition.

string $property_name: The name of the property.

Return value

string A string containing a generated column name for a field data table that is unique among all other fields.

Overrides TableMappingInterface::getFieldColumnName

2 calls to DefaultTableMapping::getFieldColumnName()
DefaultTableMapping::getColumnNames in core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
Gets a mapping of field columns to database columns for a given field.
DefaultTableMapping::getFieldTableName in core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php
Gets the table name for a given column.

File

core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php, line 204
Contains \Drupal\Core\Entity\Sql\DefaultTableMapping.

Class

DefaultTableMapping
Defines a default table mapping class.

Namespace

Drupal\Core\Entity\Sql

Code

public function getFieldColumnName(FieldStorageDefinitionInterface $storage_definition, $property_name) {
  $field_name = $storage_definition
    ->getName();
  if ($this
    ->allowsSharedTableStorage($storage_definition)) {
    $column_name = count($storage_definition
      ->getColumns()) == 1 ? $field_name : $field_name . '__' . $property_name;
  }
  elseif ($this
    ->requiresDedicatedTableStorage($storage_definition)) {
    $column_name = !in_array($property_name, $this
      ->getReservedColumns()) ? $field_name . '_' . $property_name : $property_name;
  }
  else {
    throw new SqlContentEntityStorageException("Column information not available for the '{$field_name}' field.");
  }
  return $column_name;
}