public function DownloadCountExportForm::submitForm in Download Count 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 FormInterface::submitForm
File
- src/
Form/ DownloadCountExportForm.php, line 122
Class
- DownloadCountExportForm
- Implements the Export form controller.
Namespace
Drupal\download_count\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->configFactory
->getEditable('download_count.settings')
->set('download_count_export_range', $form_state
->getValue('download_count_export_range'))
->save();
$filename = 'download_count_export_' . $form_state
->getValue('download_count_file_info')->filename . '_' . date('Y-m-d') . '.csv';
$range = $form_state
->getValue('download_count_export_range');
$start = $end = '';
if ($range > 0) {
$start = $form_state
->getValue('download_count_export_date_range_from');
$end = $form_state
->getValue('download_count_export_date_range_to');
$file = $form_state
->getValue('download_count_file_info')->filename;
$filename = 'download_count_export_' . $file . '_FROM-' . $start . '-TO-' . $end . '.csv';
}
$file_info = $form_state
->getValue('download_count_file_info');
$this
->downloadCountExportData($filename, $range, $file_info, $start, $end);
drupal_set_message($filename . ' has been successfully exported.', 'status');
}