public static function KeyValueFieldTypeTrait::schema in Key value field 8
File
- src/
Plugin/ Field/ FieldType/ KeyValueFieldTypeTrait.php, line 20
Class
- KeyValueFieldTypeTrait
- Common traits for key value field types which inherit different field types.
Namespace
Drupal\key_value_field\Plugin\Field\FieldTypeCode
public static function schema(FieldStorageDefinitionInterface $field_definition) {
// Get the schema from the big text field.
$schema = parent::schema($field_definition);
// Add an index for key.
$schema['indexes']['key'] = [
'key',
];
// Add the key and description fields.
$schema['columns'] += [
'key' => [
'description' => 'Stores the "Key" value.',
'type' => $field_definition
->getSetting('key_is_ascii') === TRUE ? 'varchar_ascii' : 'varchar',
'length' => (int) $field_definition
->getSetting('key_max_length'),
],
// Add the description db column.
'description' => [
'description' => 'Stores an optional description of the field.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
],
];
return $schema;
}