public function NodeExportForm::submitForm in Node export 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/ NodeExportForm.php, line 49
Class
- NodeExportForm
- Provides a Node Export form.
Namespace
Drupal\node_Export\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$nid = $form_state
->getValue('nid');
$data = $form_state
->getValue('export_code');
$filename = sprintf('node_%s.json', $nid);
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($filename));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . strlen($data));
print $data;
exit;
}