You are here

public function MediaSourceBase::submitConfigurationForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::submitConfigurationForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides PluginFormInterface::submitConfigurationForm

1 call to MediaSourceBase::submitConfigurationForm()
OEmbed::submitConfigurationForm in core/modules/media/src/Plugin/media/Source/OEmbed.php
Form submission handler.
1 method overrides MediaSourceBase::submitConfigurationForm()
OEmbed::submitConfigurationForm in core/modules/media/src/Plugin/media/Source/OEmbed.php
Form submission handler.

File

core/modules/media/src/MediaSourceBase.php, line 216

Class

MediaSourceBase
Base implementation of media source plugin.

Namespace

Drupal\media

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  foreach (array_intersect_key($form_state
    ->getValues(), $this->configuration) as $config_key => $config_value) {
    $this->configuration[$config_key] = $config_value;
  }

  // If no source field is explicitly set, create it now.
  if (empty($this->configuration['source_field'])) {
    $field_storage = $this
      ->createSourceFieldStorage();
    $field_storage
      ->save();
    $this->configuration['source_field'] = $field_storage
      ->getName();
  }
}