\ActionScheduler_CronSchedule

Class ActionScheduler_CronSchedule

Summary

Methods
Properties
Constants
__construct()
is_recurring()
get_first_date()
get_recurrence()
__sleep()
__wakeup()
get_next()
get_date()
next()
No public properties found
No constants found
calculate_next()
$first_timestamp
$recurrence
$scheduled_timestamp
N/A
No private methods found
$first_date
$scheduled_date
$start_timestamp
$cron
N/A

Properties

$first_timestamp

$first_timestamp : int

Timestamp equivalent of @see $this->first_date

Type

normal

$recurrence

$recurrence : mixed

The recurrence between each time an action is run using this schedule.

Used to calculate the start date & time. Can be a number of seconds, in the case of ActionScheduler_IntervalSchedule, or a cron expression, as in the case of ActionScheduler_CronSchedule. Or something else.

Type

normal

$scheduled_timestamp

$scheduled_timestamp : int

Timestamp equivalent of @see $this->scheduled_date

Type

normal

$first_date

$first_date : \DateTime

The date & time the first instance of this schedule was setup to run (which may not be this instance).

Schedule objects are attached to an action object. Each schedule stores the run date for that object as the start date - @see $this->start - and logic to calculate the next run date after that - @see $this->calculate_next(). The $first_date property also keeps a record of when the very first instance of this chain of schedules ran.

Type

\DateTime

$scheduled_date

$scheduled_date : \DateTime

The date & time the schedule is set to run.

Type

\DateTime

$start_timestamp

$start_timestamp : null

Deprecated property @see $this->__wakeup() for details.

Type

normal

$cron

$cron : null

Deprecated property @see $this->__wakeup() for details.

Type

normal

Methods

__construct()

__construct(\DateTime  $start, \CronExpression|string  $recurrence, \DateTime|null  $first = null) : mixed

Wrapper for parent constructor to accept a cron expression string and map it to a CronExpression for this objects $recurrence property.

Parameters

\DateTime $start

The date & time to run the action at or after. If $start aligns with the CronSchedule passed via $recurrence, it will be used. If it does not align, the first matching date after it will be used.

\CronExpression|string $recurrence

The CronExpression used to calculate the schedule's next instance.

\DateTime|null $first

(Optional) The date & time the first instance of this interval schedule ran. Default null, meaning this is the first instance.

Returns

mixed

is_recurring()

is_recurring() : bool

Check if a schedule should recur.

Returns

bool

get_first_date()

get_first_date() : \DateTime|null

Get the date & time of the first schedule in this recurring series.

Returns

\DateTime|null

get_recurrence()

get_recurrence() : string

Get the schedule's recurrence.

Returns

string

__sleep()

__sleep() : array

Serialize cron schedules with data required prior to AS 3.0.0

Prior to Action Scheduler 3.0.0, recurring schedules used different property names to refer to equivalent data. For example, ActionScheduler_IntervalSchedule::start_timestamp was the same as ActionScheduler_SimpleSchedule::timestamp. Action Scheduler 3.0.0 aligned properties and property names for better inheritance. To guard against the possibility of infinite loops if downgrading to Action Scheduler < 3.0.0, we need to also store the data with the old property names so if it's unserialized in AS < 3.0, the schedule doesn't end up with a null recurrence.

Returns

array

__wakeup()

__wakeup() : mixed

Unserialize cron schedules serialized/stored prior to AS 3.0.0

For more background, @see ActionScheduler_Abstract_RecurringSchedule::__wakeup().

Returns

mixed

get_next()

get_next(\DateTime  $after) : \DateTime|null

Get the next date & time when this schedule should run after a given date & time.

Parameters

\DateTime $after

Start timestamp.

Returns

\DateTime|null

get_date()

get_date() : \DateTime|null

Get the date & time the schedule is set to run.

Returns

\DateTime|null

next()

next(\DateTime  $after = null) : \DateTime|null

Get the date & time this schedule was created to run, or calculate when it should be run after a given date & time.

Parameters

\DateTime $after

DateTime to calculate against.

Returns

\DateTime|null

calculate_next()

calculate_next(\DateTime  $after) : \DateTime

Calculate when an instance of this schedule would start based on a given date & time using its the CronExpression.

Parameters

\DateTime $after

Timestamp.

Returns

\DateTime