class GarbageCollectionJob extends AbstractQueuedJob (View source)

Traits

Provides extensions to this object to integrate it with standard config API methods.

A class that can be instantiated or replaced via DI

Config options

seconds_between_jobs int

Number of seconds between job runs. Defaults to 1 day.

Properties

protected stdClass $jobData from  AbstractQueuedJob
protected array $messages from  AbstractQueuedJob
protected int $totalSteps from  AbstractQueuedJob
protected int $currentStep from  AbstractQueuedJob
protected bool $isComplete from  AbstractQueuedJob

Methods

public
__construct($params = array())

Extensions can have a construct but don't have too.

public
string
getTitle()

No description

protected
setObject(DataObject $object, string $name = 'Object')

Sets a data object for persisting by adding its id and type to the serialised vars

protected
DataObject|null
getObject(string $name = 'Object')

No description

public
string
getSignature()

Return a signature for this queued job

protected
string
randomSignature()

Generate a somewhat random signature

public
getJobType()

By default jobs should just go into the default processing queue

public
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

public
setup()

Performs setup tasks the first time this job is run.

public
prepareForRestart()

Run when an already setup job is being restarted.

public
process()

Do some processing yourself!

public
jobFinished()

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

public
afterComplete()

Called when the job is determined to be 'complete'

public
getJobData()

No description

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

No description

public
array|null
getCustomConfig()

Gets custom config settings to use when running the job.

public
setCustomConfig(array $config)

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

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

No description

public
__set(mixed $name, mixed $value)

Convenience methods for setting and getting job data

public
mixed
__get(mixed $name)

Retrieve some job data

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public static 
create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public
void
requireDefaultJob()

No description

Details

__construct($params = array())

Extensions can have a construct but don't have too.

Without a construct, it's impossible to create a job in the CMS

Parameters

$params

string getTitle()

No description

Return Value

string

protected setObject(DataObject $object, string $name = 'Object')

Sets a data object for persisting by adding its id and type to the serialised vars

Parameters

DataObject $object
string $name

A name to give it, if you want to store more than one

protected DataObject|null getObject(string $name = 'Object')

No description

Parameters

string $name

Return Value

DataObject|null

string getSignature()

Return a signature for this queued job

Return Value

string

protected string randomSignature()

Generate a somewhat random signature

useful if you're want to make sure something is always added

Return Value

string

getJobType()

By default jobs should just go into the default processing queue

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 QueuedJobService::queueJob()

Return Value

int|null

setup()

Performs setup tasks the first time this job is run.

This is only executed once for every job. If you want to run something on every job restart, use the prepareForRestart method.

prepareForRestart()

Run when an already setup job is being restarted.

process()

Do some processing yourself!

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

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')

No description

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

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

static Injectable create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.

This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();

Parameters

mixed ...$args

Return Value

Injectable

static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

void requireDefaultJob()

No description

Return Value

void