function TermStorageSchema::getSharedTableFieldSchema

Same name in other branches
  1. 9 core/modules/taxonomy/src/TermStorageSchema.php \Drupal\taxonomy\TermStorageSchema::getSharedTableFieldSchema()
  2. 10 core/modules/taxonomy/src/TermStorageSchema.php \Drupal\taxonomy\TermStorageSchema::getSharedTableFieldSchema()
  3. 11.x core/modules/taxonomy/src/TermStorageSchema.php \Drupal\taxonomy\TermStorageSchema::getSharedTableFieldSchema()

Overrides SqlContentEntityStorageSchema::getSharedTableFieldSchema

File

core/modules/taxonomy/src/TermStorageSchema.php, line 86

Class

TermStorageSchema
Defines the term schema handler.

Namespace

Drupal\taxonomy

Code

protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
    $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
    $field_name = $storage_definition->getName();
    if ($table_name == 'taxonomy_term_field_data') {
        // Remove unneeded indexes.
        unset($schema['indexes']['taxonomy_term_field__vid__target_id']);
        unset($schema['indexes']['taxonomy_term_field__description__format']);
        switch ($field_name) {
            case 'weight':
                // Improves the performance of the taxonomy_term__tree index defined
                // in getEntitySchema().
                $schema['fields'][$field_name]['not null'] = TRUE;
                break;
            case 'name':
                $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
                break;
        }
    }
    return $schema;
}

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