You are here

protected function WebformSubmissionForm::draftEnabled in Webform 8.5

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

Determine if drafts are enabled.

Return value

bool TRUE if drafts are enabled.

3 calls to WebformSubmissionForm::draftEnabled()
WebformSubmissionForm::actions in src/WebformSubmissionForm.php
Returns an array of supported actions for the current entity form.
WebformSubmissionForm::autosave in src/WebformSubmissionForm.php
Webform submission handler to autosave when there are validation errors.
WebformSubmissionForm::wizardSubmit in src/WebformSubmissionForm.php
Webform submission handler for the wizard submit action.

File

src/WebformSubmissionForm.php, line 2858

Class

WebformSubmissionForm
Provides a webform to collect and edit submissions.

Namespace

Drupal\webform

Code

protected function draftEnabled() {

  // Can't saved drafts when saving results is disabled.
  if ($this
    ->getWebformSetting('results_disabled')) {
    return FALSE;
  }

  /** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
  $webform_submission = $this
    ->getEntity();

  // Once a form is completed drafts are no longer applicable.
  if ($webform_submission
    ->isCompleted()) {
    return FALSE;
  }
  switch ($this
    ->getWebformSetting('draft')) {
    case WebformInterface::DRAFT_ALL:
      return TRUE;
    case WebformInterface::DRAFT_AUTHENTICATED:
      return $webform_submission
        ->getOwner()
        ->isAuthenticated();
    case WebformInterface::DRAFT_NONE:
    default:
      return FALSE;
  }
}