You are here

public function WebformRevisionsSubmission::getWebform in Config Entity Revisions 8

Same name and namespace in other branches
  1. 8.2 modules/webform_revisions/src/Entity/WebformRevisionsSubmission.php \Drupal\webform_revisions\Entity\WebformRevisionsSubmission::getWebform()
  2. 1.x modules/webform_revisions/src/Entity/WebformRevisionsSubmission.php \Drupal\webform_revisions\Entity\WebformRevisionsSubmission::getWebform()

Gets the webform submission's webform entity.

Return value

\Drupal\webform\WebformInterface The webform entity.

Overrides WebformSubmission::getWebform

File

modules/webform_revisions/src/Entity/WebformRevisionsSubmission.php, line 20

Class

WebformRevisionsSubmission

Namespace

Drupal\webform_revisions\Entity

Code

public function getWebform() {
  if ($this->webform) {
    return $this->webform;
  }
  $webform_id = $this->webform_id->target_id;
  $revision_id = $this->webform_revision[0];
  if ($revision_id) {

    // EntityReference doesn't understand revisions at the time of writing.
    $revision_id = $revision_id->target_id;
    $revisionsController = WebformRevisionsController::create(\Drupal::getContainer());
    $webform = $revisionsController
      ->loadConfigEntityRevision($revision_id, $webform_id);
    return $webform;
  }
  if (isset($this->webform_id->entity)) {
    return $this->webform_id->entity;
  }
  else {
    return static::$webform;
  }
}