60d68a06da4c6506fbc7ee671aa42861a8de19c6
[yaffs-website] / web / modules / contrib / media_entity / tests / modules / media_entity_test_type / src / Plugin / MediaEntity / Type / TestType.php
1 <?php
2
3 namespace Drupal\media_entity_test_type\Plugin\MediaEntity\Type;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\media_entity\Plugin\MediaEntity\Type\Generic;
7
8 /**
9  * Provides generic media type.
10  *
11  * @MediaType(
12  *   id = "test_type",
13  *   label = @Translation("Test type"),
14  *   description = @Translation("Test media type.")
15  * )
16  */
17 class TestType extends Generic {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function providedFields() {
23     return [
24       'field_1' => $this->t('Field 1'),
25       'field_2' => $this->t('Field 2'),
26     ];
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function defaultConfiguration() {
33     return [
34       'test_config_value' => 'This is default value.',
35     ];
36   }
37
38   /**
39    * {@inheritdoc}
40    */
41   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
42     $form['test_config_value'] = [
43       '#type' => 'textfield',
44       '#title' => $this->t('Test config value'),
45       '#default_value' => empty($this->configuration['test_config_value']) ? NULL : $this->configuration['test_config_value'],
46     ];
47
48     return $form;
49   }
50
51 }