You are here

public function Webform::setStatus in Webform 6.x

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

Sets the status of the configuration entity.

Parameters

bool $status: The status of the configuration entity.

Return value

$this

Overrides ConfigEntityBase::setStatus

1 call to Webform::setStatus()
Webform::preSave in src/Entity/Webform.php
Acts on an entity before the presave hook is invoked.

File

src/Entity/Webform.php, line 605

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function setStatus($status) {
  if ($status === NULL || $status === WebformInterface::STATUS_SCHEDULED) {
    $this->status = WebformInterface::STATUS_SCHEDULED;
  }
  elseif ($status === WebformInterface::STATUS_OPEN) {
    $this->status = WebformInterface::STATUS_OPEN;
  }
  elseif ($status === WebformInterface::STATUS_CLOSED) {
    $this->status = WebformInterface::STATUS_CLOSED;
  }
  else {
    $this->status = (bool) $status ? WebformInterface::STATUS_OPEN : WebformInterface::STATUS_CLOSED;
  }

  // Clear open and close if status is not scheduled.
  if ($this->status !== WebformInterface::STATUS_SCHEDULED) {
    $this->open = NULL;
    $this->close = NULL;
  }
  return $this;
}