public function MediaElementConfigForm::submitForm in MediaElement 8
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/ MediaElementConfigForm.php, line 285
Class
- MediaElementConfigForm
- Configuration form for MediaElement.js module.
Namespace
Drupal\mediaelement\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->configFactory
->getEditable('mediaelement.settings');
$library_settings = [];
$library_settings['library_source'] = $form_state
->getValue('library_source');
// If connecting to a CDN, save their settings.
if ($library_settings['library_source'] != 'local') {
$cdn_name = $library_settings['library_source'];
$cdn_settings_fields = [
'library_version',
];
$library_settings["{$cdn_name}_settings"] = $this
->getConfigurationValues($cdn_settings_fields, $form_state);
}
$config
->set('library_settings', $library_settings);
$global_settings = [];
$global_settings['attach_sitewide'] = $form_state
->getValue('attach_sitewide');
$player_settings_fields = [
'class_prefix',
'set_dimensions',
];
$global_settings['player_settings'] = $this
->getConfigurationValues($player_settings_fields, $form_state);
$video_settings_fields = [
'default_video_width',
'default_video_height',
'video_width',
'video_height',
];
$global_settings['video_settings'] = $this
->getConfigurationValues($video_settings_fields, $form_state);
$audio_settings_fields = [
'default_audio_width',
'default_audio_height',
'audio_width',
'audio_height',
];
$global_settings['audio_settings'] = $this
->getConfigurationValues($audio_settings_fields, $form_state);
$config
->set('global_settings', $global_settings);
$config
->save();
parent::submitForm($form, $form_state);
}