function SqlContentEntityStorageSchema::createDedicatedTableSchema

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

Creates the schema for a field stored in a dedicated table.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The storage definition of the field being created.

bool $only_save: (optional) Whether to skip modification of database tables and only save the schema data for future comparison. For internal use only. This is used by postUpdateEntityTypeSchema() after it has already fully created the dedicated tables.

2 calls to SqlContentEntityStorageSchema::createDedicatedTableSchema()
SqlContentEntityStorageSchema::onFieldableEntityTypeCreate in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Reacts to the creation of the fieldable entity type.
SqlContentEntityStorageSchema::postUpdateEntityTypeSchema in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php
Allows subscribers to do any cleanup necessary after data copying.

File

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

Class

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

Namespace

Drupal\Core\Entity\Sql

Code

protected function createDedicatedTableSchema(FieldStorageDefinitionInterface $storage_definition, $only_save = FALSE) {
    $schema = $this->getDedicatedTableSchema($storage_definition);
    if (!$only_save) {
        foreach ($schema as $name => $table) {
            // Check if the table exists because it might already have been
            // created as part of the earlier entity type update event.
            if (!$this->database
                ->schema()
                ->tableExists($name)) {
                $this->database
                    ->schema()
                    ->createTable($name, $table);
            }
        }
    }
    $this->saveFieldSchemaData($storage_definition, $schema);
}

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