You are here

public function SettingsForm::submitForm in File metadata manager 8

Same name and namespace in other branches
  1. 8.2 src/Form/SettingsForm.php \Drupal\file_mdm\Form\SettingsForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

src/Form/SettingsForm.php, line 120

Class

SettingsForm
Configures file_mdm settings for this site.

Namespace

Drupal\file_mdm\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Call the form submit handler for each of the plugins.
  foreach ($this->metadataPlugins as $plugin) {
    $plugin
      ->submitConfigurationForm($form, $form_state);
  }
  $this
    ->config('file_mdm.settings')
    ->set('metadata_cache', $form_state
    ->getValue([
    'metadata_cache',
    'settings',
  ]));

  // Only save settings if they have changed to prevent unnecessary cache
  // invalidations.
  if ($this
    ->config('file_mdm.settings')
    ->getOriginal() != $this
    ->config('file_mdm.settings')
    ->get()) {
    $this
      ->config('file_mdm.settings')
      ->save();
  }
  parent::submitForm($form, $form_state);
}