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

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

5 6
use Drupal\Component\Utility\Random;
use Drupal\Core\Field\FieldDefinitionInterface;
7
use Drupal\Core\Field\FieldStorageDefinitionInterface;
8 9 10 11 12 13

/**
 * Defines the 'string_long' field type.
 *
 * @FieldType(
 *   id = "string_long",
14 15
 *   label = @Translation("Text (plain, long)"),
 *   description = @Translation("A field containing a long string value."),
16
 *   category = @Translation("Text"),
17
 *   default_widget = "string_textarea",
18
 *   default_formatter = "basic_string",
19 20
 * )
 */
21
class StringLongItem extends StringItemBase {
22

23 24 25
  /**
   * {@inheritdoc}
   */
26
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
27 28 29
    return [
      'columns' => [
        'value' => [
30
          'type' => $field_definition->getSetting('case_sensitive') ? 'blob' : 'text',
31
          'size' => 'big',
32 33 34
        ],
      ],
    ];
35 36
  }

37 38 39
  /**
   * {@inheritdoc}
   */
40 41 42 43
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $random = new Random();
    $values['value'] = $random->paragraphs();
    return $values;
44 45
  }

46
}