You are here

public function WebformSubmission::getState in Webform 6.x

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

Track the state of a submission.

Return value

string Either STATE_UNSAVED, STATE_DRAFT_CREATED, STATE_DRAFT_UPDATED, STATE_COMPLETED, STATE_UPDATED, STATE_LOCKED, or STATE_CONVERTED depending on the last save operation performed.

Overrides WebformSubmissionInterface::getState

File

src/Entity/WebformSubmission.php, line 698

Class

WebformSubmission
Defines the WebformSubmission entity.

Namespace

Drupal\webform\Entity

Code

public function getState() {
  if (!$this
    ->id()) {
    return WebformSubmissionInterface::STATE_UNSAVED;
  }
  elseif ($this
    ->isConverting()) {
    return WebformSubmissionInterface::STATE_CONVERTED;
  }
  elseif ($this
    ->isDraft()) {
    return $this->created->value === $this->changed->value ? WebformSubmissionInterface::STATE_DRAFT_CREATED : WebformSubmissionInterface::STATE_DRAFT_UPDATED;
  }
  elseif ($this
    ->isLocked()) {
    return WebformSubmissionInterface::STATE_LOCKED;
  }
  elseif ($this->completed->value === $this->changed->value) {
    return WebformSubmissionInterface::STATE_COMPLETED;
  }
  else {
    return WebformSubmissionInterface::STATE_UPDATED;
  }
}