Symbiote\QueuedJobs\Services\AbstractQueuedJob
A base implementation of a queued job that provides some convenience for implementations
This implementation assumes that when you created your job class, you initialised the
jobData with relevant variables needed to process() your job later on in execution. If you do not,
please ensure you do before you queueJob() the job, to ensure the signature that is generated is 'correct'.
- Author: Marcus Nyeholt <marcus@symbiote.com.au>
- License: BSD http://silverstripe.org/bsd-license/
Synopsis
class AbstractQueuedJob
implements
QueuedJob,UserContextInterface
{
- // members
- protected stdClass $jobData;
- protected array $messages = ;
- protected integer $totalSteps = 0;
- protected integer $currentStep = 0;
- protected boolean $isComplete = false;
- // methods
- public void __construct()
- public abstract string getTitle()
- protected void setObject()
- protected DataObject|null getObject()
- public string getSignature()
- protected string randomSignature()
- public string getJobType()
- public void getRunAsMemberID()
- public void setup()
- public void prepareForRestart()
- public abstract void process()
- public void jobFinished()
- public void afterComplete()
- public stdClass getJobData()
- public void setJobData()
- public array|null getCustomConfig()
- public void setCustomConfig()
- private void loadCustomConfig()
- public void addMessage()
- public void __set()
- public mixed __get()
Hierarchy
Implements
Constants
Name | Value |
---|---|
IMMEDIATE | '1' |
QUEUED | '2' |
LARGE | '3' |
STATUS_NEW | 'New' |
STATUS_INIT | 'Initialising' |
STATUS_RUN | 'Running' |
STATUS_WAIT | 'Waiting' |
STATUS_COMPLETE | 'Complete' |
STATUS_PAUSED | 'Paused' |
STATUS_CANCELLED | 'Cancelled' |
STATUS_BROKEN | 'Broken' |
Members
protected
- $currentStep — int
- $isComplete — boolean
- $jobData — stdClass
- $messages — array
- $totalSteps — int
Methods
private
- loadCustomConfig() — Sets custom configuration settings from the job data.
protected
- getObject()
- randomSignature() — Generate a somewhat random signature
- setObject() — Sets a data object for persisting by adding its id and type to the serialised vars
public
- __construct() — Extensions can have a construct but don't have too.
- __get() — Retrieve some job data
- __set() — Convenience methods for setting and getting job data
- addMessage()
- afterComplete() — Called when the job is determined to be 'complete'
- getCustomConfig() — Gets custom config settings to use when running the job.
- getJobData()
- getJobType() — By default jobs should just go into the default processing queue
- getRunAsMemberID()
- getSignature() — Return a signature for this queued job
- getTitle()
- jobFinished() — Method for determining whether the job is finished - you may override it if there's more to it than just this
- prepareForRestart() — Run when an already setup job is being restarted.
- process() — Do some processing yourself!
- setCustomConfig() — Sets custom config settings to use when the job is run.
- setJobData()
- setup() — Performs setup tasks the first time this job is run.