6c98205f4f19987519e7117e1f786c66323de49d
[yaffs-website] / web / core / modules / field / tests / modules / field_test / src / Plugin / Field / FieldType / TestItemWithPreconfiguredOptions.php
1 <?php
2
3 namespace Drupal\field_test\Plugin\Field\FieldType;
4
5 use Drupal\Core\Field\FieldStorageDefinitionInterface;
6 use Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface;
7
8 /**
9  * Defines the 'test_field_with_preconfigured_options' entity field item.
10  *
11  * @FieldType(
12  *   id = "test_field_with_preconfigured_options",
13  *   label = @Translation("Test field with preconfigured options"),
14  *   description = @Translation("Dummy field type used for tests."),
15  *   default_widget = "test_field_widget",
16  *   default_formatter = "field_test_default"
17  * )
18  */
19 class TestItemWithPreconfiguredOptions extends TestItem implements PreconfiguredFieldUiOptionsInterface {
20
21   /**
22    * {@inheritdoc}
23    */
24   public static function getPreconfiguredOptions() {
25     return [
26       'custom_options' => [
27         'label' => t('All custom options'),
28         'category' => t('Custom category'),
29         'field_storage_config' => [
30           'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
31           'settings' => [
32             'test_field_storage_setting' => 'preconfigured_storage_setting',
33           ],
34         ],
35         'field_config' => [
36           'required' => TRUE,
37           'settings' => [
38             'test_field_setting' => 'preconfigured_field_setting',
39           ],
40         ],
41         'entity_form_display' => [
42           'type' => 'test_field_widget_multiple',
43         ],
44         'entity_view_display' => [
45           'type' => 'field_test_multiple',
46         ],
47       ],
48     ];
49   }
50
51 }