You are here

public function JsonWebformExporter::writeSubmission in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformExporter/JsonWebformExporter.php \Drupal\webform\Plugin\WebformExporter\JsonWebformExporter::writeSubmission()

Write submission to export.

Parameters

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

Overrides WebformExporterBase::writeSubmission

File

src/Plugin/WebformExporter/JsonWebformExporter.php, line 24

Class

JsonWebformExporter
Defines a JSON document exporter.

Namespace

Drupal\webform\Plugin\WebformExporter

Code

public function writeSubmission(WebformSubmissionInterface $webform_submission) {
  $file_name = $this
    ->getSubmissionBaseName($webform_submission) . '.json';
  $json = Json::encode($webform_submission
    ->toArray(TRUE, TRUE));
  $this
    ->addToArchive($json, $file_name);
}