3 namespace Drupal\entity_browser\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7 use Drupal\Core\Render\Element;
8 use Drupal\entity_browser\EntityBrowserInterface;
11 * Base class for steps in entity browser form wizard.
13 abstract class PluginConfigFormBase extends FormBase {
18 public function buildForm(array $form, FormStateInterface $form_state) {
19 /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
20 $entity_browser = $form_state->getTemporaryValue('wizard')['entity_browser'];
21 $form = $this->getPlugin($entity_browser)->buildConfigurationForm($form, $form_state);
23 $fields = Element::children($form);
25 $form['no_options'] = [
28 '#markup' => $this->t('This plugin has no configuration options.'),
38 public function validateForm(array &$form, FormStateInterface $form_state) {
39 /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
40 $entity_browser = $form_state->getTemporaryValue('wizard')['entity_browser'];
41 $this->getPlugin($entity_browser)->validateConfigurationForm($form, $form_state);
47 public function submitForm(array &$form, FormStateInterface $form_state) {
48 /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
49 $entity_browser = $form_state->getTemporaryValue('wizard')['entity_browser'];
50 $this->getPlugin($entity_browser)->submitConfigurationForm($form, $form_state);
54 * Gets plugin that form operates with.
56 * @return \Drupal\Core\Plugin\PluginFormInterface|\Drupal\Component\Plugin\PluginInspectionInterface
59 abstract public function getPlugin(EntityBrowserInterface $entity_browser);