public static function LanguageKeyValueItem::schema in Lingotek Translation 3.5.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 8.2 src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 4.0.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.0.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.1.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.2.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.3.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.4.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.6.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.7.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
- 3.8.x src/Plugin/Field/FieldType/LanguageKeyValueItem.php \Drupal\lingotek\Plugin\Field\FieldType\LanguageKeyValueItem::schema()
Returns the schema for the field.
This method is static because the field schema information is needed on creation of the field. FieldItemInterface objects instantiated at that time are not reliable as field settings might be missing.
Computed fields having no schema should return an empty array.
Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface $field_definition: The field definition.
Return value
array An empty array if there is no schema, or an associative array with the following key/value pairs:
- columns: An array of Schema API column specifications, keyed by column name. The columns need to be a subset of the properties defined in propertyDefinitions(). The 'not null' property is ignored if present, as it is determined automatically by the storage controller depending on the table layout and the property definitions. It is recommended to avoid having the column definitions depend on field settings when possible. No assumptions should be made on how storage engines internally use the original column name to structure their storage.
- unique keys: (optional) An array of Schema API unique key definitions. Only columns that appear in the 'columns' array are allowed.
- indexes: (optional) An array of Schema API index definitions. Only columns that appear in the 'columns' array are allowed. Those indexes will be used as default indexes. Field definitions can specify additional indexes or, at their own risk, modify the default indexes specified by the field-type module. Some storage engines might not support indexes.
- foreign keys: (optional) An array of Schema API foreign key definitions. Note, however, that the field data is not necessarily stored in SQL. Also, the possible usage is limited, as you cannot specify another field as related, only existing SQL tables, such as {taxonomy_term_data}.
Overrides StringItem::schema
File
- src/
Plugin/ Field/ FieldType/ LanguageKeyValueItem.php, line 27
Class
- LanguageKeyValueItem
- Plugin implementation of the 'language_key_value' field type.
Namespace
Drupal\lingotek\Plugin\Field\FieldTypeCode
public static function schema(FieldStorageDefinitionInterface $field_definition) {
// Get the schema from the text field.
$schema = parent::schema($field_definition);
// Add an index for key.
$schema['indexes']['language'] = [
'language',
];
$schema['columns'] += [
'language' => [
'description' => 'Stores the "Language" value.',
'type' => 'varchar_ascii',
'length' => 12,
'not null' => TRUE,
'default' => '',
],
];
return $schema;
}