class PublishItemsJob extends AbstractQueuedJob implements QueuedJob (View source)

An example queued job

Use this as an example of how you can write your own jobs

Methods

__construct(DataObject $rootNodeID = null)

No description

string
getTitle()

Defines the title of the job

string
getSignature()

Return a signature for this queued job

getJobType()

Indicate to the system which queue we think we should be in based on how many objects we're going to touch on while processing.

int|null
getRunAsMemberID()

Specifies what user ID should be when running the job valid values: null - (default) - run the job as current user 0 - run the job without a user greater than zero - run the job as a specific user

setup()

This is called immediately before a job begins - it gives you a chance to initialise job data and make sure everything's good to go

prepareForRestart()

Run when an already setup job is being restarted.

process()

Lets process a single node, and publish it if necessary

jobFinished()

Method for determining whether the job is finished - you may override it if there's more to it than just this

afterComplete()

Called when the job is determined to be 'complete'

getJobData()

No description

setJobData(int $totalSteps, int $currentStep, bool $isComplete, stdClass $jobData, array $messages)

No description

array|null
getCustomConfig()

Gets custom config settings to use when running the job.

setCustomConfig(array $config)

Sets custom config settings to use when the job is run.

addMessage(string $message, string $severity = 'INFO')

No description

__set(mixed $name, mixed $value)

Convenience methods for setting and getting job data

mixed
__get(mixed $name)

Retrieve some job data

Details

__construct(DataObject $rootNodeID = null)

Parameters

DataObject $rootNodeID

string getTitle()

Defines the title of the job

Return Value

string

string getSignature()

Return a signature for this queued job

Return Value

string

getJobType()

Indicate to the system which queue we think we should be in based on how many objects we're going to touch on while processing.

We want to make sure we also set how many steps we think we might need to take to process everything - note that this does not need to be 100% accurate, but it's nice to give a reasonable approximation

int|null getRunAsMemberID()

Specifies what user ID should be when running the job valid values: null - (default) - run the job as current user 0 - run the job without a user greater than zero - run the job as a specific user

This is useful in situations like:

  • a job needs to always run without a user (like a static cache job)
  • a job needs to run as a specific user (for example data migration job)

Note that this value can be overridden in the see QueuedJobService::queueJob()

Return Value

int|null

setup()

This is called immediately before a job begins - it gives you a chance to initialise job data and make sure everything's good to go

What we're doing in our case is to queue up the list of items we know we need to process still (it's not everything - just the ones we know at the moment)

When we go through, we'll constantly add and remove from this queue, meaning we never overload it with content

prepareForRestart()

Run when an already setup job is being restarted.

process()

Lets process a single node, and publish it if necessary

jobFinished()

Method for determining whether the job is finished - you may override it if there's more to it than just this

afterComplete()

Called when the job is determined to be 'complete'

setJobData(int $totalSteps, int $currentStep, bool $isComplete, stdClass $jobData, array $messages)

Parameters

int $totalSteps
int $currentStep
bool $isComplete
stdClass $jobData
array $messages

array|null getCustomConfig()

Gets custom config settings to use when running the job.

Return Value

array|null

setCustomConfig(array $config)

Sets custom config settings to use when the job is run.

Parameters

array $config

addMessage(string $message, string $severity = 'INFO')

Parameters

string $message
string $severity

__set(mixed $name, mixed $value)

Convenience methods for setting and getting job data

Parameters

mixed $name
mixed $value

mixed __get(mixed $name)

Retrieve some job data

Parameters

mixed $name

Return Value

mixed