TimedJob extends Job
Simple base class to extend to run periodic background jobs.
Call setInterval with your desired interval in seconds from the constructor.
Tags
Table of Contents
- $argument : mixed
- $id : int
- $interval : int
- $lastRun : int
- $time : ITimeFactory
- __construct() : mixed
- execute() : mixed
- run the job if the last run is is more than the interval ago
- getArgument() : mixed
- Get the argument associated with the background job This is the argument that will be passed to the background job
- getId() : int
- Get the id of the background job This id is determined by the job list when a job is added to the list
- getLastRun() : int
- Get the last time this job was run as unix timestamp
- setArgument() : mixed
- setId() : mixed
- setInterval() : mixed
- set the interval for the job
- setLastRun() : mixed
- run() : mixed
- The actual function that is called to run the job
Properties
$argument
protected
mixed
$argument
$id
protected
int
$id
$interval
protected
int
$interval
= 0
$lastRun
protected
int
$lastRun
$time
protected
ITimeFactory
$time
Methods
__construct()
public
__construct(ITimeFactory $time) : mixed
Parameters
- $time : ITimeFactory
Tags
Return values
mixed —execute()
run the job if the last run is is more than the interval ago
public
final execute(JobList $jobList[, ILogger|null $logger = null ]) : mixed
Parameters
- $jobList : JobList
-
The job list that manages the state of this job
- $logger : ILogger|null = null
Tags
Return values
mixed —getArgument()
Get the argument associated with the background job This is the argument that will be passed to the background job
public
getArgument() : mixed
Tags
Return values
mixed —getId()
Get the id of the background job This id is determined by the job list when a job is added to the list
public
final getId() : int
Tags
Return values
int —getLastRun()
Get the last time this job was run as unix timestamp
public
final getLastRun() : int
Tags
Return values
int —setArgument()
public
setArgument(mixed $argument) : mixed
Parameters
- $argument : mixed
Tags
Return values
mixed —setId()
public
final setId(mixed $id) : mixed
Parameters
- $id : mixed
Tags
Return values
mixed —setInterval()
set the interval for the job
public
setInterval(int $interval) : mixed
Parameters
- $interval : int
Tags
Return values
mixed —setLastRun()
public
final setLastRun(mixed $lastRun) : mixed
Parameters
- $lastRun : mixed
Tags
Return values
mixed —run()
The actual function that is called to run the job
protected
abstract run( $argument) : mixed