public function SettingsForm::submitForm in Entity Print 8.2
Same name and namespace in other branches
- 8 src/Form/SettingsForm.php \Drupal\entity_print\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 216
Class
- SettingsForm
- Defines a form that configures Entity Print settings.
Namespace
Drupal\entity_print\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('entity_print.settings');
foreach ($this->exportTypeManager
->getDefinitions() as $export_type => $definition) {
if ($plugin_id = $form_state
->getValue($export_type)) {
$entity = $this
->loadConfigEntity($plugin_id);
/** @var \Drupal\entity_print\Plugin\PrintEngineInterface $plugin */
$plugin = $entity
->getPrintEnginePluginCollection()
->get($entity
->id());
$plugin
->submitConfigurationForm($form, $form_state);
$entity
->save();
}
// Save the plugin as the default for this engine type.
$config
->set('print_engines.' . $export_type . '_engine', $plugin_id);
}
// Save the global settings.
$values = $form_state
->getValues();
$config
->set('default_css', $values['default_css'])
->set('force_download', $values['force_download'])
->save();
$this
->messenger()
->addStatus($this
->t('Configuration saved.'));
}