public function FontSettingsForm::submitForm in @font-your-face 8.3
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/ FontSettingsForm.php, line 114
Class
- FontSettingsForm
- Form to define the fonts.
Namespace
Drupal\fontyourface\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$op = (string) $values['op'];
$batch = [
'title' => $this
->t('Importing...'),
'operations' => [],
'finished' => '\\Drupal\\fontyourface\\Form\\FontSettingsForm::importFinished',
];
foreach (\Drupal::moduleHandler()
->getImplementations('fontyourface_import') as $module_name) {
if ($op == $this
->t('Import all fonts') || $op == $this
->t('Import from @module', [
'@module' => $module_name,
])) {
$batch['operations'][] = [
'\\Drupal\\fontyourface\\Form\\FontSettingsForm::importFromProvider',
[
$module_name,
],
];
}
}
if (!empty($batch['operations'])) {
batch_set($batch);
}
if ($op == $this
->t('Save configuration')) {
$config = $this
->config('fontyourface.settings')
->set('load_all_enabled_fonts', $values['load_all_enabled_fonts'])
->set('load_on_themes', $values['load_on_themes'])
->save();
parent::submitForm($form, $form_state);
}
// Resave enabled fonts.
$fonts = Font::loadActivatedFonts();
foreach ($fonts as $font) {
$font
->activate();
}
}