Nextcloud PHP API (master)

Job
in package
implements IJob, IParallelAwareJob

AbstractYes

Base class for background jobs

This is here if you want to do advanced stuff in your background jobs. For the most common use cases have a look at QueuedJob and TimedJob

Tags
since
15.0.0
since
25.0.0

deprecated execute() method in favor of start()

since
33.0.0

removed deprecated execute() method

Table of Contents

Interfaces

IJob
This interface represents a background job run with cron
IParallelAwareJob

Properties

$allowParallelRuns  : bool
$argument  : mixed
$id  : string
$lastRun  : int
$time  : ITimeFactory

Methods

__construct()  : mixed
getAllowParallelRuns()  : bool
getArgument()  : mixed
Get the argument associated with the background job This is the argument that will be passed to the background job
getId()  : string
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
setAllowParallelRuns()  : void
Set this to false to prevent two Jobs from the same class from running in parallel
setArgument()  : void
setId()  : void
setLastRun()  : void
start()  : void
Start the background job with the registered argument
run()  : mixed

Properties

$allowParallelRuns

protected bool $allowParallelRuns = true

$argument

protected mixed $argument = null

$id

protected string $id = '0'

$lastRun

protected int $lastRun = 0

Methods

getAllowParallelRuns()

public getAllowParallelRuns() : bool
Attributes
#[Override]
Return values
bool

getArgument()

Get the argument associated with the background job This is the argument that will be passed to the background job

public getArgument() : mixed
Attributes
#[Override]

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() : string
Attributes
#[Override]
Return values
string

getLastRun()

Get the last time this job was run as unix timestamp

public final getLastRun() : int
Attributes
#[Override]
Return values
int

setAllowParallelRuns()

Set this to false to prevent two Jobs from the same class from running in parallel

public setAllowParallelRuns(bool $allow) : void
Parameters
$allow : bool
Attributes
#[Override]

setArgument()

public setArgument(mixed $argument) : void
Parameters
$argument : mixed
Attributes
#[Override]

setId()

public final setId(string $id) : void
Parameters
$id : string
Attributes
#[Override]

setLastRun()

public final setLastRun(int $lastRun) : void
Parameters
$lastRun : int
Attributes
#[Override]

start()

Start the background job with the registered argument

public start(IJobList $jobList) : void

This methods will take care of running the background job, of initializing the state and cleaning up the job list after running the job.

For common background job scenario, you will want to use TimedJob or QueuedJob instead of overwriting this method.

Parameters
$jobList : IJobList

The job list that manages the state of this job

Attributes
#[Override]

run()

protected abstract run(mixed $argument) : mixed
Parameters
$argument : mixed

        
On this page

Search results