You are here

public function Webform::getCacheMaxAge in Webform 8.5

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

The maximum age for which this object may be cached.

Return value

int The maximum time in seconds that this object may be cached.

Overrides EntityBase::getCacheMaxAge

File

src/Entity/Webform.php, line 2274

Class

Webform
Defines the webform entity.

Namespace

Drupal\webform\Entity

Code

public function getCacheMaxAge() {
  if ($this
    ->isScheduled()) {
    $time = time();
    if ($this->open && strtotime($this->open) > $time) {
      return strtotime($this->open) - $time;
    }
    elseif ($this->close && strtotime($this->close) > $time) {
      return strtotime($this->close) - $time;
    }
  }
  return parent::getCacheMaxAge();
}