Same name and namespace in other branches
  1. 8.x-2.x src/Plugin/Field/FieldType/ColorFieldType.php \Drupal\color_field\Plugin\Field\FieldType\ColorFieldType::schema() 1 comment

File

src/Plugin/Field/FieldType/ColorFieldType.php, line 202

Class

ColorFieldType
Plugin implementation of the 'color_type' field type.

Namespace

Drupal\color_field\Plugin\Field\FieldType

Code

public static function schema(FieldStorageDefinitionInterface $field_definition) : array {
    $format = $field_definition->getSetting('format');
    $color_length = isset($format) ? strlen($format) : 7;
    return [
        'columns' => [
            'color' => [
                'description' => 'The color value',
                'type' => 'varchar',
                'length' => $color_length,
                'not null' => FALSE,
            ],
            'opacity' => [
                'description' => 'The opacity/alphavalue property',
                'type' => 'float',
                'size' => 'tiny',
                'not null' => FALSE,
            ],
        ],
        'indexes' => [
            'color' => [
                'color',
            ],
        ],
    ];
}