You are here

protected function ReferenceStorageSchema::getDedicatedTableSchema in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/ReferenceStorageSchema.php \Drupal\bibcite_entity\ReferenceStorageSchema::getDedicatedTableSchema()

Gets the SQL schema for a dedicated table.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The field storage definition.

\Drupal\Core\Entity\ContentEntityTypeInterface $entity_type: (optional) The entity type definition. Defaults to the one provided by the entity storage.

Return value

array The schema definition for the table with the following keys:

  • fields: The schema definition for the each field columns.
  • indexes: The schema definition for the indexes.
  • unique keys: The schema definition for the unique keys.
  • foreign keys: The schema definition for the foreign keys.

Throws

\Drupal\Core\Field\FieldException Exception thrown if the schema contains reserved column names.

Overrides SqlContentEntityStorageSchema::getDedicatedTableSchema

See also

hook_schema()

File

modules/bibcite_entity/src/ReferenceStorageSchema.php, line 46

Class

ReferenceStorageSchema
Defines the reference schema handler.

Namespace

Drupal\bibcite_entity

Code

protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $storage_definition, ContentEntityTypeInterface $entity_type = NULL) {
  $schema = parent::getDedicatedTableSchema($storage_definition, $entity_type);
  if ($storage_definition
    ->getName() === 'bibcite_citekey') {

    /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
    $table_mapping = $this->storage
      ->getTableMapping();
    $dedicated_table_name = $table_mapping
      ->getDedicatedDataTableName($storage_definition);
    $revision_dedicated_table_name = $table_mapping
      ->getDedicatedRevisionTableName($storage_definition);
    $column_name = $table_mapping
      ->getFieldColumnName($storage_definition, 'value');
    $schema[$dedicated_table_name]['indexes']['value'] = [
      $column_name,
    ];
    $schema[$revision_dedicated_table_name]['indexes']['value'] = [
      $column_name,
    ];
  }
  return $schema;
}