function SqlContentEntityStorageSchema::getSchemaFromStorageDefinition

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

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.

2 calls to SqlContentEntityStorageSchema::getSchemaFromStorageDefinition()
SqlContentEntityStorageSchema::hasColumnChanges in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Compares schemas to check for changes in the column definitions.
SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Checks if the changes to the storage definition requires schema changes.

File

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

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->getTableMapping($this->entityType, [
        $storage_definition,
    ]);
    $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;
}

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