ActionScheduler_CronSchedule
ActionScheduler_CronSchedule represents a recurring schedule based on a cron expression and the CronExpression parser.
Class definition
class ActionScheduler_CronSchedule extends ActionScheduler_Abstract_RecurringSchedule implements ActionScheduler_Schedule {
public function __construct( DateTime $start, $recurrence, ?DateTime $first = null );
protected function calculate_next( DateTime $after );
public function get_recurrence();
public function __sleep();
public function __wakeup();
}
When it’s used
Use this schedule for recurring actions that follow cron-style timing rules (e.g., “every day at midnight”, “every third Monday”).
Construction and cron parsing
public function __construct( DateTime $start, $recurrence, ?DateTime $first = null );
$recurrencecan be aCronExpressioninstance or a cron expression string.- If a string is passed, it is converted via
CronExpression::factory( $recurrence ).
The constructor normalizes the initial run date so it matches the cron expression:
$date = $recurrence->getNextRunDate( $start, 0, true );
true for the third argument ensures that if $start already matches the cron expression, it is accepted as-is; otherwise the next matching date is used.
$first defaults to $start (not $date) to preserve the originally requested start time as the “first” reference.
Next-run calculation
calculate_next() asks the cron parser for the next run after $after:
return $this->recurrence->getNextRunDate( $after, 0, false );
So get_next( DateTime $after ) returns:
- the stored schedule date if
$afteris before or equal to the scheduled date - otherwise the next matching cron run after
$after
Recurrence
is_recurring()is inherited and returnstrue.get_recurrence()returns the cron expression as a string viastrval( $this->recurrence ).
Serialization compatibility
__sleep()/__wakeup() preserve compatibility with schedules serialized before Action Scheduler 3.0.0 by mapping legacy property names (start_timestamp, cron).