StringItem.php 996 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 12

/**
13
 * Defines the 'string' entity field type.
14
 *
15 16 17
 * @FieldType(
 *   id = "string",
 *   label = @Translation("String"),
18
 *   description = @Translation("An entity field containing a string value."),
19
 *   configurable = FALSE
20
 * )
21 22 23 24
 */
class StringItem extends FieldItemBase {

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

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

38 39
    if (!isset(static::$propertyDefinitions)) {
      static::$propertyDefinitions['value'] = array(
40 41 42 43
        'type' => 'string',
        'label' => t('Text value'),
      );
    }
44
    return static::$propertyDefinitions;
45 46
  }
}