You are here

public function WebformSubmission::getData in Webform 8.5

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

Gets the webform submission's data with computed valued.

Return value

array The webform submission data with computed valued.

Overrides WebformSubmissionInterface::getData

2 calls to WebformSubmission::getData()
WebformSubmission::getElementData in src/Entity/WebformSubmission.php
Get a webform submission element's data.
WebformSubmission::toArray in src/Entity/WebformSubmission.php
Gets an array of all property values.

File

src/Entity/WebformSubmission.php, line 427

Class

WebformSubmission
Defines the WebformSubmission entity.

Namespace

Drupal\webform\Entity

Code

public function getData() {
  if (isset($this->computedData)) {
    return $this->computedData;
  }

  // If there is no active theme and we can't prematurely start computing
  // element values because it will define and lock the active theme.

  /** @var \Drupal\webform\WebformThemeManagerInterface $theme_manager */
  $theme_manager = \Drupal::service('webform.theme_manager');
  if (!$theme_manager
    ->hasActiveTheme()) {
    return $this->data;
  }

  // Set computed element values in to submission data.
  $this->computedData = $this->data;
  $webform = $this
    ->getWebform();
  if ($webform
    ->hasComputed()) {

    /** @var \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager */
    $element_manager = \Drupal::service('plugin.manager.webform.element');
    $computed_elements = $webform
      ->getElementsComputed();
    foreach ($computed_elements as $computed_element_name) {
      $computed_element = $webform
        ->getElement($computed_element_name);

      /** @var \Drupal\webform\Plugin\WebformElementComputedInterface $element_plugin */
      $element_plugin = $element_manager
        ->getElementInstance($computed_element);
      $this->computedData[$computed_element_name] = $element_plugin
        ->computeValue($computed_element, $this);
    }
  }
  return $this->computedData;
}