FloatItem.php 1 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\FieldItemBase;
11
use Drupal\Core\TypedData\DataDefinition;
12 13

/**
14
 * Defines the 'float' entity field type.
15
 *
16 17 18
 * @FieldType(
 *   id = "float",
 *   label = @Translation("Float"),
19
 *   description = @Translation("An entity field containing an float value."),
20
 *   configurable = FALSE
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 * )
 */
class FloatItem extends FieldItemBase {

  /**
   * Definitions of the contained properties.
   *
   * @see IntegerItem::getPropertyDefinitions()
   *
   * @var array
   */
  static $propertyDefinitions;

  /**
   * Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions().
   */
  public function getPropertyDefinitions() {

    if (!isset(static::$propertyDefinitions)) {
40 41
      static::$propertyDefinitions['value'] = DataDefinition::create('float')
        ->setLabel(t('Float value'));
42 43 44 45
    }
    return static::$propertyDefinitions;
  }
}