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

Table of Contents

Interfaces

IJob
This interface represents a background job run with cron
IParallelAwareJob

Properties

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

Methods

__construct()  : mixed
execute()  : void
The function to prepare the execution of the job.
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()  : 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
setAllowParallelRuns()  : void
Set this to false to prevent two Jobs from this class from running in parallel
setArgument()  : mixed
setId()  : mixed
setLastRun()  : mixed
start()  : void
Start the background job with the registered argument
run()  : void
The actual function that is called to run the job

Properties

$allowParallelRuns

protected bool $allowParallelRuns = true

$argument

protected mixed $argument

$id

protected int $id = 0

$lastRun

protected int $lastRun = 0

Methods

execute()

The function to prepare the execution of the job.

public execute(IJobList $jobList[, ILogger|null $logger = null ]) : void

Use start() instead. This method will be removed with the ILogger interface

Parameters
$jobList : IJobList

The job list that manages the state of this job

$logger : ILogger|null = null
Tags
since
15.0.0

getAllowParallelRuns()

public getAllowParallelRuns() : bool
Tags
since
27.0.0
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
Tags
since
15.0.0

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
since
15.0.0
Return values
int

getLastRun()

Get the last time this job was run as unix timestamp

public final getLastRun() : int
Tags
since
15.0.0
Return values
int

setAllowParallelRuns()

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

public setAllowParallelRuns(bool $allow) : void
Parameters
$allow : bool
Tags
since
27.0.0

setArgument()

public setArgument(mixed $argument) : mixed
Parameters
$argument : mixed
Tags
since
15.0.0

setId()

public final setId(int $id) : mixed
Parameters
$id : int
Tags
since
15.0.0

setLastRun()

public final setLastRun(int $lastRun) : mixed
Parameters
$lastRun : int
Tags
since
15.0.0

start()

Start the background job with the registered argument

public start(IJobList $jobList) : void
Parameters
$jobList : IJobList

The job list that manages the state of this job

Tags
inheritdoc
since
25.0.0

run()

The actual function that is called to run the job

protected abstract run(mixed $argument) : void
Parameters
$argument : mixed
Tags
since
15.0.0

        
On this page

Search results