public function Cron::addTask in Anti Spam by CleanTalk 8.4
Same name and namespace in other branches
- 9.1.x src/lib/Cleantalk/Common/Cron.php \Cleantalk\Common\Cron::addTask()
Adding new cron task.
Parameters
string $task:
string $handler:
int $period:
null|int $first_call:
array $params:
Return value
bool
1 call to Cron::addTask()
- Cron::updateTask in src/
lib/ Cleantalk/ Common/ Cron.php - Updates cron task, create task if not exists.
File
- src/
lib/ Cleantalk/ Common/ Cron.php, line 96
Class
- Cron
- CleanTalk Cron class
Namespace
Cleantalk\CommonCode
public function addTask($task, $handler, $period, $first_call = null, $params = array()) {
// First call time() + period
$first_call = !$first_call ? time() + $period : $first_call;
if (isset($this->tasks[$task])) {
return false;
}
// Task entry
$this->tasks[$task] = array(
'handler' => $handler,
'next_call' => $first_call,
'period' => $period,
'params' => $params,
);
return $this
->saveTasks($this->tasks);
}