StringItem.php 960 Bytes
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\Core\Entity\Plugin\Field\FieldType\StringItem.
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 'string' entity field type.
15
 *
16 17 18
 * @FieldType(
 *   id = "string",
 *   label = @Translation("String"),
19
 *   description = @Translation("An entity field containing a string value."),
20
 *   configurable = FALSE
21
 * )
22 23 24 25
 */
class StringItem extends FieldItemBase {

  /**
26
   * Definitions of the contained properties.
27
   *
28
   * @see StringItem::getPropertyDefinitions()
29 30 31 32 33 34
   *
   * @var array
   */
  static $propertyDefinitions;

  /**
35
   * {@inheritdoc}
36 37 38
   */
  public function getPropertyDefinitions() {

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