public DefaultTableMapping::getFieldTableName($field_name)
Gets the table name for a given column.
Parameters
string $field_name: The name of the entity field to return the column mapping for.
Return value
string Table name for the given field.
Throws
\Drupal\Core\Entity\Sql\SqlContentEntityStorageException
Overrides TableMappingInterface::getFieldTableName
File
- core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php, line 137
 
Class
- DefaultTableMapping
 - Defines a default table mapping class.
 
Namespace
Drupal\Core\Entity\Sql
Code
public function getFieldTableName($field_name) {
  $result = NULL;
  if (isset($this->fieldStorageDefinitions[$field_name])) {
    // Since a field may be stored in more than one table, we inspect tables
    // in order of relevance: the data table if present is the main place
    // where field data is stored, otherwise the base table is responsible for
    // storing field data. Revision metadata is an exception as it's stored
    // only in the revision table.
    // @todo The table mapping itself should know about entity tables. See
    //   https://www.drupal.org/node/2274017.
    /** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $storage */
    $storage = \Drupal::entityManager()->getStorage($this->entityType->id());
    $storage_definition = $this->fieldStorageDefinitions[$field_name];
    $table_names = array(
      $storage->getDataTable(),
      $storage->getBaseTable(),
      $storage->getRevisionTable(),
      $this->getDedicatedDataTableName($storage_definition),
    );
    // Collect field columns.
    $field_columns = array();
    foreach (array_keys($storage_definition->getColumns()) as $property_name) {
      $field_columns[] = $this->getFieldColumnName($storage_definition, $property_name);
    }
    foreach (array_filter($table_names) as $table_name) {
      $columns = $this->getAllColumns($table_name);
      // We assume finding one field column belonging to the mapping is enough
      // to identify the field table.
      if (array_intersect($columns, $field_columns)) {
        $result = $table_name;
        break;
      }
    }
  }
  if (!isset($result)) {
    throw new SqlContentEntityStorageException("Table information not available for the '$field_name' field.");
  }
  return $result;
}
Please login to continue.