You are here

public function WebformSubmissionGenerate::getData in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionGenerate.php \Drupal\webform\WebformSubmissionGenerate::getData()

Generate webform submission data.

Parameters

\Drupal\webform\WebformInterface $webform: The webform this submission will be added to.

Return value

array An associative array containing webform submission data.

Overrides WebformSubmissionGenerateInterface::getData

File

src/WebformSubmissionGenerate.php, line 75

Class

WebformSubmissionGenerate
Webform submission generator.

Namespace

Drupal\webform

Code

public function getData(WebformInterface $webform) {
  $elements = $webform
    ->getElementsInitializedAndFlattened();
  $data = [];
  foreach ($elements as $key => $element) {
    $value = $this
      ->getTestValue($webform, $key, $element);
    if ($value !== NULL) {
      $data[$key] = $value;
    }
  }
  return $data;
}