\Charcoal\ObjectObjectSchedule

The object schedule class allows object properties to be changed at a scheduled time.

Required Services

  • "model/factory" — \Charcoal\Model\ModelFactory

Summary

Methods
Properties
Constants
setModelFactory()
setTargetType()
targetType()
setTargetId()
targetId()
setDataDiff()
dataDiff()
setProcessed()
processed()
setScheduledDate()
scheduledDate()
setProcessedDate()
processedDate()
preSave()
process()
No public properties found
No constants found
modelFactory()
No protected properties found
N/A
No private methods found
$modelFactory
$targetType
$targetId
$scheduledDate
$dataDiff
$processed
$processedDate
N/A

Properties

$modelFactory

$modelFactory : \Charcoal\Factory\FactoryInterface

Store the factory instance for the current class.

Type

\Charcoal\Factory\FactoryInterface

$targetType

$targetType : string

The object type of the scheduled object (required).

Type

string

$targetId

$targetId : mixed

The object ID of the scheduled object (required).

Type

mixed

$scheduledDate

$scheduledDate : \DateTimeInterface

When the item should be processed.

The date/time at which this queue item job should be ran. If NULL, 0, or a past date/time, then it should be performed immediately.

Type

\DateTimeInterface

$dataDiff

$dataDiff : string

The property identifier of the scheduled object (required).

Type

string

$processed

$processed : boolean

Whether the item has been processed.

Type

boolean

$processedDate

$processedDate : \DateTimeInterface

When the item was processed.

Type

\DateTimeInterface

Methods

setModelFactory()

setModelFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Object\ObjectContainerInterface

Set an object model factory.

Parameters

\Charcoal\Factory\FactoryInterface $factory

The model factory, to create objects.

Returns

\Charcoal\Object\ObjectContainerInterface —

Chainable

setTargetType()

setTargetType(string  $targetType) : \Charcoal\Object\ObjectScheduleInterface

Set the scheduled object's type.

Parameters

string $targetType

The object type (model).

Throws

\InvalidArgumentException

If the object type parameter is not a string.

Returns

\Charcoal\Object\ObjectScheduleInterface

Chainable

targetType()

targetType() : string

Retrieve the scheduled object's type.

Returns

string

setTargetId()

setTargetId(mixed  $targetId) : \Charcoal\Object\ObjectScheduleInterface

Set the scheduled object's ID.

Parameters

mixed $targetId

The object ID.

Returns

\Charcoal\Object\ObjectScheduleInterface

Chainable

targetId()

targetId() : mixed

Retrieve the scheduled object's ID.

Returns

mixed

setDataDiff()

setDataDiff(array|string  $data) : \Charcoal\Object\ObjectRevision

Parameters

array|string $data

The data diff.

Returns

\Charcoal\Object\ObjectRevision

dataDiff()

dataDiff() : array

Returns

array

setProcessed()

setProcessed(boolean  $processed) : \Charcoal\Object\ObjectScheduleInterface

Set the schedule's processed status.

Parameters

boolean $processed

Whether the schedule has been processed.

Returns

\Charcoal\Object\ObjectScheduleInterface

Chainable

processed()

processed() : boolean

Determine if the schedule has been processed.

Returns

boolean

setScheduledDate()

setScheduledDate(null|string|\DateTimeInterface  $ts) : \Charcoal\Object\QueueItemInterface

Set the date/time the item should be processed at.

Parameters

null|string|\DateTimeInterface $ts

A date/time string or object.

Throws

\InvalidArgumentException

If the date/time is invalid.

Returns

\Charcoal\Object\QueueItemInterface —

Chainable

scheduledDate()

scheduledDate() : null|\DateTimeInterface

Retrieve the date/time the item should be processed at.

Returns

null|\DateTimeInterface

setProcessedDate()

setProcessedDate(null|string|\DateTimeInterface  $ts) : \Charcoal\Object\QueueItemInterface

Set the date/time the item was processed at.

Parameters

null|string|\DateTimeInterface $ts

A date/time string or object.

Throws

\InvalidArgumentException

If the date/time is invalid.

Returns

\Charcoal\Object\QueueItemInterface —

Chainable

processedDate()

processedDate() : null|\DateTimeInterface

Retrieve the date/time the item was processed at.

Returns

null|\DateTimeInterface

preSave()

preSave() : \Charcoal\Object\QueueItemInterface

Hook called before saving the item.

Presets the item as to-be processed and queued now.

Returns

\Charcoal\Object\QueueItemInterface —

Chainable

process()

process(callable  $callback = null, callable  $successCallback = null, callable  $failureCallback = null) : boolean

Process the item.

Parameters

callable $callback

An optional callback routine executed after the item is processed.

callable $successCallback

An optional callback routine executed when the item is resolved.

callable $failureCallback

An optional callback routine executed when the item is rejected.

Returns

boolean —

Success / Failure

modelFactory()

modelFactory() : \Charcoal\Factory\FactoryInterface

Retrieve the object model factory.

Throws

\RuntimeException

If the model factory was not previously set.

Returns

\Charcoal\Factory\FactoryInterface