protected function SqlContentEntityStorageSchema::getSchemaFromStorageDefinition

protected SqlContentEntityStorageSchema::getSchemaFromStorageDefinition(FieldStorageDefinitionInterface $storage_definition)

Gets the schema data for the given field storage definition.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The field storage definition. The field that must not have custom storage, i.e. the storage must take care of storing the field.

Return value

array The schema data.

File

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

Class

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

Namespace

Drupal\Core\Entity\Sql

Code

protected function getSchemaFromStorageDefinition(FieldStorageDefinitionInterface $storage_definition) {
  assert('!$storage_definition->hasCustomStorage();');
  $table_mapping = $this->storage->getTableMapping();
  $schema = [];
  if ($table_mapping->requiresDedicatedTableStorage($storage_definition)) {
    $schema = $this->getDedicatedTableSchema($storage_definition);
  }
  elseif ($table_mapping->allowsSharedTableStorage($storage_definition)) {
    $field_name = $storage_definition->getName();
    foreach (array_diff($table_mapping->getTableNames(), $table_mapping->getDedicatedTableNames()) as $table_name) {
      if (in_array($field_name, $table_mapping->getFieldNames($table_name))) {
        $column_names = $table_mapping->getColumnNames($storage_definition->getName());
        $schema[$table_name] = $this->getSharedTableFieldSchema($storage_definition, $table_name, $column_names);
      }
    }
  }
  return $schema;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorageSchema.php/function/SqlContentEntityStorageSchema::getSchemaFromStorageDefinition/8.1.x