Completed
Pull Request — 8.x-1.x (#126)
by Janez
06:19
created

WidgetSelectorBase::defaultConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * @file
5
 * Contains \Drupal\entity_browser\WidgetSelectorBase.
6
 */
7
8
namespace Drupal\entity_browser;
9
10
use Drupal\Core\Plugin\PluginBase;
11
use Drupal\Core\Form\FormStateInterface;
12
13
/**
14
 * Base class for widget selector plugins.
15
 */
16
abstract class WidgetSelectorBase extends PluginBase implements WidgetSelectorInterface {
17
18
  use PluginConfigurationFormTrait;
19
20
  /**
21
   * Plugin label.
22
   *
23
   * @var string
24
   */
25
  protected $label;
26
27
  /**
28
   * Available widgets.
29
   *
30
   * @var array()
31
   */
32
  protected $widgets_options;
33
34
  /**
35
   * ID of the default widget.
36
   *
37
   * @var string
38
   */
39
  protected $defaultWidget;
40
41
  /**
42
   * {@inheritdoc}
43
   */
44
  public function __construct($configuration, $plugin_id, $plugin_definition) {
45
    parent::__construct($configuration, $plugin_id, $plugin_definition);
46
    $this->widget_ids = $this->configuration['widget_ids'];
47
  }
48
49
  /**
50
   * {@inheritdoc}
51
   */
52
  public function defaultConfiguration() {
53
    return [];
54
  }
55
56
  /**
57
   * {@inheritdoc}
58
   */
59
  public function getConfiguration() {
60
    return array_diff_key(
61
      $this->configuration,
62
      ['widget_ids' => 0]
63
    );
64
  }
65
66
  /**
67
   * {@inheritdoc}
68
   */
69
  public function setConfiguration(array $configuration) {
70
    $this->configuration = $configuration;
71
  }
72
73
  /**
74
   * {@inheritdoc}
75
   */
76
  public function calculateDependencies() {
77
    return [];
78
  }
79
80
  /**
81
   * {@inheritdoc}
82
   */
83
  public function label() {
84
    return $this->label;
85
  }
86
87
  /**
88
   * {@inheritdoc}
89
   */
90
  protected function getDefaultWidget() {
91
    return $this->defaultWidget;
92
  }
93
94
  /**
95
   * {@inheritdoc}
96
   */
97
  public function setDefaultWidget($widget) {
98
    $this->defaultWidget = $widget;
99
  }
100
101
  /**
102
   * {@inheritdoc}
103
   */
104
  public function validate(array &$form, FormStateInterface $form_state) {}
105
106
  /**
107
   * {@inheritdoc}
108
   */
109
  public function submit(array &$form, FormStateInterface $form_state) {}
110
111
}
112