You are here

public function Webform::isOpen in Webform 8.5

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

Returns the webform opened status indicator.

Return value

bool TRUE if the webform is open to new submissions.

Overrides WebformInterface::isOpen

2 calls to Webform::isOpen()
Webform::isClosed in src/Entity/Webform.php
Returns the webform closed status indicator.
Webform::status in src/Entity/Webform.php
Returns whether the configuration entity is enabled.

File

src/Entity/Webform.php, line 638

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function isOpen() {

  // Archived webforms are always closed.
  if ($this
    ->isArchived()) {
    return FALSE;
  }
  switch ($this->status) {
    case WebformInterface::STATUS_OPEN:
      return TRUE;
    case WebformInterface::STATUS_CLOSED:
      return FALSE;
    case WebformInterface::STATUS_SCHEDULED:
      $is_opened = TRUE;
      if ($this->open && strtotime($this->open) > time()) {
        $is_opened = FALSE;
      }
      $is_closed = FALSE;
      if ($this->close && strtotime($this->close) < time()) {
        $is_closed = TRUE;
      }
      return $is_opened && !$is_closed ? TRUE : FALSE;
  }
  return FALSE;
}