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

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

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

10
use Drupal\Core\Field\FieldDefinitionInterface;
11
use Drupal\Core\Field\FieldItemBase;
12
use Drupal\Core\TypedData\DataDefinition;
13 14

/**
15
 * Defines the 'float' entity field type.
16
 *
17 18 19
 * @FieldType(
 *   id = "float",
 *   label = @Translation("Float"),
20
 *   description = @Translation("An entity field containing an float value."),
21
 *   configurable = FALSE
22 23 24 25 26
 * )
 */
class FloatItem extends FieldItemBase {

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

33
    return $properties;
34
  }
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldDefinitionInterface $field_definition) {
    return array(
      'columns' => array(
        'value' => array(
          'type' => 'float',
          'not null' => FALSE,
        ),
      ),
    );
  }

50
}