You are here

class Cron in Anti Spam by CleanTalk 8.4

Same name in this branch
  1. 8.4 src/lib/Cleantalk/Common/Cron.php \Cleantalk\Common\Cron
  2. 8.4 src/lib/Cleantalk/ApbctDrupal/Cron.php \Cleantalk\ApbctDrupal\Cron
Same name and namespace in other branches
  1. 9.1.x src/lib/Cleantalk/ApbctDrupal/Cron.php \Cleantalk\ApbctDrupal\Cron

Hierarchy

  • class \Cleantalk\Common\Cron
    • class \Cleantalk\ApbctDrupal\Cron

Expanded class hierarchy of Cron

2 files declare their use of Cron
BootSubscriber.php in src/EventSubscriber/BootSubscriber.php
CleantalkFuncs.php in src/CleantalkFuncs.php

File

src/lib/Cleantalk/ApbctDrupal/Cron.php, line 5

Namespace

Cleantalk\ApbctDrupal
View source
class Cron extends \Cleantalk\Common\Cron {
  public function saveTasks($tasks) {
    \Drupal::state()
      ->set($this->cron_option_name, array(
      'last_start' => time(),
      'tasks' => $tasks,
    ));
  }

  /**
   * Getting all tasks
   *
   * @return array
   */
  public function getTasks() {
    $cron = \Drupal::state()
      ->get($this->cron_option_name);
    return !empty($cron) && isset($cron['tasks']) ? $cron['tasks'] : null;
  }

  /**
   * Save option with tasks
   *
   * @return int timestamp
   */
  public function getCronLastStart() {
    $cron = \Drupal::state()
      ->get($this->cron_option_name);
    return !empty($cron) && isset($cron['last_start']) ? $cron['last_start'] : 0;
  }

  /**
   * Save timestamp of running Cron.
   *
   * @return bool
   */
  public function setCronLastStart() {
    \Drupal::state()
      ->set($this->cron_option_name, array(
      'last_start' => time(),
      'tasks' => $this
        ->getTasks(),
    ));
    return true;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Cron::$cron_execution_min_interval protected property
Cron::$cron_option_name protected property
Cron::$debug public property
Cron::$tasks protected property
Cron::$tasks_completed protected property
Cron::$task_execution_min_interval protected property
Cron::addTask public function Adding new cron task.
Cron::checkTasks public function Getting tasks which should be run
Cron::getCronLastStart public function Save option with tasks Overrides Cron::getCronLastStart
Cron::getCronOptionName public function Get cron option name
Cron::getTasks public function Getting all tasks Overrides Cron::getTasks
Cron::removeTask public function Removing cron task
Cron::runTasks public function Run all tasks from $this->tasks_to_run. Saving all results to (array) $this->tasks_completed
Cron::saveTasks public function Save option with tasks Overrides Cron::saveTasks
Cron::setCronLastStart public function Save timestamp of running Cron. Overrides Cron::setCronLastStart
Cron::updateTask public function Updates cron task, create task if not exists.
Cron::__construct public function Cron constructor. Getting tasks option.