You are here

public function FormatConfigurationFormPdf::submitForm in Printer and PDF versions for Drupal 8+ 8

Same name and namespace in other branches
  1. 2.x src/Form/FormatConfigurationFormPdf.php \Drupal\printable\Form\FormatConfigurationFormPdf::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 FormInterface::submitForm

File

src/Form/FormatConfigurationFormPdf.php, line 219

Class

FormatConfigurationFormPdf
Provides shared configuration form for all printable formats.

Namespace

Drupal\printable\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $pdf_tool = $this
    ->config('printable.settings')
    ->get('pdf_tool');
  $this->configFactory
    ->getEditable('printable.settings')
    ->set('pdf_tool', $form_state
    ->getValue('print_pdf_pdf_tool'))
    ->set('save_pdf', $form_state
    ->getValue('print_pdf_content_disposition'))
    ->set('ignore_warnings', $form_state
    ->getValue('print_pdf_ignore_warnings'))
    ->set('paper_size', (string) $form_state
    ->getValue('print_pdf_paper_size'))
    ->set('page_orientation', $form_state
    ->getValue('print_pdf_page_orientation'))
    ->set('pdf_location', $form_state
    ->getValue('print_pdf_filename'))
    ->save();
  if (ClassLoader::classExists('mikehaertl\\wkhtmlto\\Pdf') && $pdf_tool == 'wkhtmltopdf') {
    $this->configFactory
      ->getEditable('printable.settings')
      ->set('path_to_binary', $form_state
      ->getValue('path_to_binary'))
      ->set('print_pdf_use_xvfb_run', $form_state
      ->getValue('print_pdf_use_xvfb_run'))
      ->set('path_to_xfb_run', $form_state
      ->getValue('path_to_xfb_run'))
      ->save();
  }
  drupal_set_message('The configuration option has been saved', 'status');
}