Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / Field / Plugin / Field / FieldType / StringLongItem.php
1 <?php
2
3 namespace Drupal\Core\Field\Plugin\Field\FieldType;
4
5 use Drupal\Component\Utility\Random;
6 use Drupal\Core\Field\FieldDefinitionInterface;
7 use Drupal\Core\Field\FieldStorageDefinitionInterface;
8
9 /**
10  * Defines the 'string_long' field type.
11  *
12  * @FieldType(
13  *   id = "string_long",
14  *   label = @Translation("Text (plain, long)"),
15  *   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    * {@inheritdoc}
25    */
26   public static function schema(FieldStorageDefinitionInterface $field_definition) {
27     return [
28       'columns' => [
29         'value' => [
30           'type' => $field_definition->getSetting('case_sensitive') ? 'blob' : 'text',
31           'size' => 'big',
32         ],
33       ],
34     ];
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
41     $random = new Random();
42     $values['value'] = $random->paragraphs();
43     return $values;
44   }
45
46 }