FloatItem.php 1.1 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\Core\Field\Plugin\Field\FieldType\FloatItem.
6 7
 */

8
namespace Drupal\Core\Field\Plugin\Field\FieldType;
9

10
use Drupal\Core\Field\FieldStorageDefinitionInterface;
11
use Drupal\Core\TypedData\DataDefinition;
12 13

/**
14
 * Defines the 'float' field type.
15
 *
16 17
 * @FieldType(
 *   id = "float",
18 19 20 21
 *   label = @Translation("Number (float)"),
 *   description = @Translation("This field stores a number in the database in a floating point format."),
 *   default_widget = "number",
 *   default_formatter = "number_decimal"
22 23
 * )
 */
24
class FloatItem extends NumericItemBase {
25 26

  /**
27
   * {@inheritdoc}
28
   */
29
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
30 31
    $properties['value'] = DataDefinition::create('float')
      ->setLabel(t('Float value'));
32

33
    return $properties;
34
  }
35 36 37 38

  /**
   * {@inheritdoc}
   */
39
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
40 41 42 43 44 45 46 47 48 49
    return array(
      'columns' => array(
        'value' => array(
          'type' => 'float',
          'not null' => FALSE,
        ),
      ),
    );
  }

50
}