You are here

public function AutoBlockScheduler::evaluate in Auto Block Scheduler 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Condition/AutoBlockScheduler.php \Drupal\auto_block_scheduler\Plugin\Condition\AutoBlockScheduler::evaluate()

Evaluates the condition and returns TRUE or FALSE accordingly.

Return value

bool TRUE if the condition has been met, FALSE otherwise.

Overrides ConditionInterface::evaluate

File

src/Plugin/Condition/AutoBlockScheduler.php, line 65

Class

AutoBlockScheduler
Provides a 'AutoBlockScheduler ' condition.

Namespace

Drupal\auto_block_scheduler\Plugin\Condition

Code

public function evaluate() {
  $status = TRUE;
  if (empty($this->configuration['published_on']) && empty($this->configuration['unpublished_on']) && !$this
    ->isNegated()) {
    return TRUE;
  }
  if (!empty($this->configuration['published_on'])) {
    $status = $status && time() >= $this->configuration['published_on'];
  }
  if (!empty($this->configuration['unpublished_on'])) {
    $status = $status && time() <= $this->configuration['unpublished_on'];
  }
  return $status;
}