You are here

public function AdminSettingsForm::submitForm in PDF using mPDF 8

Same name and namespace in other branches
  1. 8.2 src/Form/AdminSettingsForm.php \Drupal\pdf_using_mpdf\Form\AdminSettingsForm::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/AdminSettingsForm.php, line 410

Class

AdminSettingsForm
Admin settings form.

Namespace

Drupal\pdf_using_mpdf\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $settings = [
    'pdf_filename' => $values['pdf_filename'],
    'pdf_save_option' => $values['pdf_save_option'],
    'pdf_set_title' => $values['pdf_set_title'],
    'pdf_set_author' => $values['pdf_set_author'],
    'pdf_set_subject' => $values['pdf_set_subject'],
    'pdf_set_creator' => $values['pdf_set_creator'],
    'margin_top' => $values['margin_top'],
    'margin_right' => $values['margin_right'],
    'margin_bottom' => $values['margin_bottom'],
    'margin_left' => $values['margin_left'],
    'margin_header' => $values['margin_header'],
    'margin_footer' => $values['margin_footer'],
    'pdf_font_size' => $values['pdf_font_size'],
    'pdf_default_font' => $values['pdf_default_font'],
    'pdf_page_size' => $values['pdf_page_size'],
    'dpi' => $values['dpi'],
    'img_dpi' => $values['img_dpi'],
    'orientation' => $values['orientation'],
    'watermark_option' => $values['watermark_option'],
    'watermark_opacity' => $values['watermark_opacity'],
    'pdf_watermark_text' => $values['pdf_watermark_text'],
    'watermark_image' => $values['watermark_image'],
    'pdf_header' => $values['pdf_header'],
    'pdf_footer' => $values['pdf_footer'],
    'pdf_css_file' => $values['pdf_css_file'],
    'enabled_content_types' => $values['enabled_content_types'] ? $values['enabled_content_types'] : [],
  ];
  if (isset($values['remove_pwd'])) {
    if ($values['remove_pwd'] == '1') {
      $settings['pdf_password'] = NULL;
    }
  }
  else {
    $settings['pdf_password'] = $values['pdf_password'];
  }

  // Save the configuration into database.
  $this
    ->configFactory()
    ->getEditable('pdf_using_mpdf.settings')
    ->set('pdf_using_mpdf', $settings)
    ->save();
  parent::submitForm($form, $form_state);
}