function DefaultTableMapping::getFieldColumnName

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

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 425

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)) {
        if ($property_name == TableMappingInterface::DELTA) {
            $column_name = 'delta';
        }
        else {
            $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;
}

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