You are here

YamlWebformExporter.php in Webform 6.x

Same filename and directory in other branches
  1. 8.5 src/Plugin/WebformExporter/YamlWebformExporter.php

File

src/Plugin/WebformExporter/YamlWebformExporter.php
View source
<?php

namespace Drupal\webform\Plugin\WebformExporter;

use Drupal\webform\Utility\WebformYaml;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Defines a YAML document exporter.
 *
 * @WebformExporter(
 *   id = "yaml",
 *   label = @Translation("YAML documents"),
 *   description = @Translation("Exports results as YAML documents."),
 *   archive = TRUE,
 *   options = FALSE,
 * )
 */
class YamlWebformExporter extends DocumentBaseWebformExporter {

  /**
   * {@inheritdoc}
   */
  public function writeSubmission(WebformSubmissionInterface $webform_submission) {
    $file_name = $this
      ->getSubmissionBaseName($webform_submission) . '.yml';
    $yaml = WebformYaml::encode($webform_submission
      ->toArray(TRUE, TRUE));
    $this
      ->addToArchive($yaml, $file_name);
  }

}

Classes

Namesort descending Description
YamlWebformExporter Defines a YAML document exporter.