Completed
Push — 8.x-1.x ( 48b271...fbaab6 )
by Janez
02:46
created

PluginConfigFormBase::submitForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/**
4
 * @file
5
 * Contains \Drupal\entity_browser\Form\PluginConfigFormBase.
6
 */
7
8
namespace Drupal\entity_browser\Form;
9
10
use Drupal\Core\Form\FormBase;
11
use Drupal\Core\Form\FormStateInterface;
12
use Drupal\entity_browser\EntityBrowserInterface;
13
14
/**
15
 * Base class for steps in entity browser form wizard.
16
 */
17
abstract class PluginConfigFormBase extends FormBase {
18
19
  /**
20
   * {@inheritdoc}
21
   */
22
  public function buildForm(array $form, FormStateInterface $form_state) {
23
    /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
24
    $entity_browser = $form_state->getTemporaryValue('wizard')['entity_browser'];
25
    $form = $this->getPlugin($entity_browser)->buildConfigurationForm($form, $form_state);
26
    return $form;
27
  }
28
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function validateForm(array &$form, FormStateInterface $form_state) {
33
    /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
34
    $entity_browser = $form_state->getTemporaryValue('wizard')['entity_browser'];
35
    $this->getPlugin($entity_browser)->validateConfigurationForm($form, $form_state);
36
  }
37
38
  /**
39
   * {@inheritdoc}
40
   */
41
  public function submitForm(array &$form, FormStateInterface $form_state) {
42
    /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
43
    $entity_browser = $form_state->getTemporaryValue('wizard')['entity_browser'];
44
    $this->getPlugin($entity_browser)->submitConfigurationForm($form, $form_state);
45
  }
46
47
  /**
48
   * Gets plugin that form operates with.
49
   *
50
   * @return \Drupal\Core\Plugin\PluginFormInterface
51
   *   Plugin instance.
52
   */
53
  abstract public function getPlugin(EntityBrowserInterface $entity_browser);
54
55
}
56