Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
mod_scorm\task\cron_task Class Reference

A cron_task class to be used by Tasks API. More...

Inheritance diagram for mod_scorm\task\cron_task:
core\task\scheduled_task core\task\task_base

Public Member Functions

 can_run ()
 Informs whether this task can be run.
 
 eval_cron_field ($field, $min, $max)
 Take a cron field definition and return an array of valid numbers with the range min-max.
 
 execute ()
 Run scorm cron.
 
 get_component ()
 Getter for $component.
 
 get_cron_lock ()
 Get the current lock for the entire cron.
 
 get_day ()
 Getter for $day.
 
 get_day_of_week ()
 Getter for $dayofweek.
 
 get_disabled ()
 Getter for $disabled.
 
 get_fail_delay ()
 Getter for $faildelay.
 
 get_hostname ()
 Getter for $hostname.
 
 get_hour ()
 Getter for $hour.
 
 get_last_run_time ()
 Get the last run time for this scheduled task.
 
 get_lock ()
 Get the current lock for this task.
 
 get_minute ()
 Getter for $minute.
 
 get_month ()
 Getter for $month.
 
 get_name ()
 Get a descriptive name for this task (shown to admins).
 
 get_next_run_time ()
 Get the next run time for this task.
 
 get_next_scheduled_time (int $now=0)
 Calculate when this task should next be run based on the schedule.
 
 get_pid ()
 Getter for $pid.
 
 get_run_if_component_disabled ()
 Override this function if you want this scheduled task to run, even if the component is disabled.
 
 get_runtime ()
 Returns task runtime.
 
 get_runtime_result ()
 Returns if the task has been running for too long.
 
 get_timestarted ()
 Getter for $timestarted.
 
 is_blocking ()
 Getter for $blocking.
 
 is_component_enabled ()
 Informs whether the task's component is enabled.
 
 is_customised ()
 Has this task been changed from it's default config?
 
 is_enabled ()
 Checks whether the component and the task disabled flag enables to run this task.
 
 is_overridden ()
 Has this task been changed from it's default config?
 
 is_valid (string $field)
 Informs whether the given field is valid.
 
 set_blocking ($blocking)
 Setter for $blocking.
 
 set_component ($component)
 Setter for $component.
 
 set_cron_lock (\core\lock\lock $lock)
 Set the current lock for the entire cron process.
 
 set_customised ($customised)
 Has this task been changed from it's default config?
 
 set_day ($day)
 Setter for $day.
 
 set_day_of_week ($dayofweek, $expandr=true)
 Setter for $dayofweek.
 
 set_disabled ($disabled)
 Setter for $disabled.
 
 set_fail_delay ($faildelay)
 Setter for $faildelay.
 
 set_hostname ($hostname=null)
 Setter for $hostname.
 
 set_hour ($hour, $expandr=true)
 Setter for $hour.
 
 set_last_run_time ($lastruntime)
 Set the last run time for this scheduled task.
 
 set_lock (\core\lock\lock $lock)
 Set the current lock for this task.
 
 set_minute ($minute, $expandr=true)
 Setter for $minute.
 
 set_month ($month)
 Setter for $month.
 
 set_next_run_time ($nextruntime)
 Set the next run time for this task.
 
 set_overridden (bool $overridden)
 Set the overridden value.
 
 set_pid ($pid=null)
 Setter for $pid.
 
 set_timestarted ($timestarted=null)
 Setter for $timestarted.
 

Static Public Member Functions

static get_html_id (string $classname)
 Produces a valid id string to use as id attribute based on the given FQCN class name.
 

Public Attributes

const DAYMAX = 31
 Maximum day of month value.
 
const DAYMIN = 1
 Minimum day of month value.
 
const DAYOFWEEKMAX = 6
 Maximum dayofweek value.
 
const DAYOFWEEKMAXINPUT = 7
 Maximum dayofweek value allowed in input (7 = 0).
 
const DAYOFWEEKMIN = 0
 Minimum dayofweek value.
 
const FIELD_DAY = 'day'
 Day-of-month field identifier.
 
const FIELD_DAYOFWEEK = 'dayofweek'
 Day-of-week field identifier.
 
const FIELD_HOUR = 'hour'
 Hour field identifier.
 
const FIELD_MINUTE = 'minute'
 Minute field identifier.
 
const FIELD_MONTH = 'month'
 Month field identifier.
 
const HOURMAX = 23
 Maximum hour value.
 
const HOURMIN = 0
 Minimum hour value.
 
const MINUTEMAX = 59
 Maximum minute value.
 
const MINUTEMIN = 0
 Minimum minute value.
 
const MONTHMAX = 12
 Maximum month value.
 
const MONTHMIN = 1
 Minimum month value.
 
const NEVER_RUN_TIME = 7952342400
 Time used for the next scheduled time when a task should never run.
 

Protected Member Functions

 get_next_scheduled_time_inner (int $now, array $validminutes, array $validhours, array $validdays, array $validdaysofweek, array $validmonths, int $originalyear=0)
 Recursively calculate the next valid time for this task.
 

Detailed Description

A cron_task class to be used by Tasks API.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ can_run()

core\task\scheduled_task::can_run ( )
inherited

Informs whether this task can be run.

Return values
booltrue when this task can be run. false otherwise.

Reimplemented in cachestore_redis\task\ttl.

◆ eval_cron_field()

core\task\scheduled_task::eval_cron_field ( $field,
$min,
$max )
inherited

Take a cron field definition and return an array of valid numbers with the range min-max.

Parameters
string$field- The field definition.
int$min- The minimum allowable value.
int$max- The maximum allowable value.
Return values
array(int)

◆ execute()

mod_scorm\task\cron_task::execute ( )

Run scorm cron.

Reimplemented from core\task\task_base.

◆ get_component()

core\task\task_base::get_component ( )
inherited

Getter for $component.

Return values
string

◆ get_cron_lock()

core\task\task_base::get_cron_lock ( )
inherited

Get the current lock for the entire cron.

Return values
core\lock\lock

◆ get_day()

core\task\scheduled_task::get_day ( )
inherited

Getter for $day.

Return values
string

◆ get_day_of_week()

core\task\scheduled_task::get_day_of_week ( )
inherited

Getter for $dayofweek.

Return values
string

◆ get_disabled()

core\task\scheduled_task::get_disabled ( )
inherited

Getter for $disabled.

Return values
bool

◆ get_fail_delay()

core\task\task_base::get_fail_delay ( )
inherited

Getter for $faildelay.

Return values
int

◆ get_hostname()

core\task\task_base::get_hostname ( )
inherited

Getter for $hostname.

Return values
string

◆ get_hour()

core\task\scheduled_task::get_hour ( )
inherited

Getter for $hour.

Return values
string

◆ get_html_id()

static core\task\scheduled_task::get_html_id ( string $classname)
staticinherited

Produces a valid id string to use as id attribute based on the given FQCN class name.

Parameters
string$classnameFQCN of a task.
Return values
stringvalid string to be used as id attribute.

◆ get_last_run_time()

core\task\scheduled_task::get_last_run_time ( )
inherited

Get the last run time for this scheduled task.

Return values
int

◆ get_lock()

core\task\task_base::get_lock ( )
inherited

Get the current lock for this task.

Return values
core\lock\lock

◆ get_minute()

core\task\scheduled_task::get_minute ( )
inherited

Getter for $minute.

Return values
string

◆ get_month()

core\task\scheduled_task::get_month ( )
inherited

Getter for $month.

Return values
string

◆ get_name()

mod_scorm\task\cron_task::get_name ( )

Get a descriptive name for this task (shown to admins).

Return values
string

Reimplemented from core\task\task_base.

◆ get_next_run_time()

core\task\task_base::get_next_run_time ( )
inherited

Get the next run time for this task.

Return values
inttimestamp

◆ get_next_scheduled_time()

core\task\scheduled_task::get_next_scheduled_time ( int $now = 0)
inherited

Calculate when this task should next be run based on the schedule.

Parameters
int$nowCurrent time, for testing (leave 0 to use default time)
Return values
int\$nextruntime,.

◆ get_next_scheduled_time_inner()

core\task\scheduled_task::get_next_scheduled_time_inner ( int $now,
array $validminutes,
array $validhours,
array $validdays,
array $validdaysofweek,
array $validmonths,
int $originalyear = 0 )
protectedinherited

Recursively calculate the next valid time for this task.

Parameters
int$nowStart time
array$validminutesValid minutes
array$validhoursValid hours
array$validdaysValid days
array$validdaysofweekValid days of week
array$validmonthsValid months
int$originalyearZero for first call, original year for recursive calls
Return values
intNext run time

◆ get_pid()

core\task\task_base::get_pid ( )
inherited

Getter for $pid.

Return values
int

◆ get_run_if_component_disabled()

core\task\scheduled_task::get_run_if_component_disabled ( )
inherited

Override this function if you want this scheduled task to run, even if the component is disabled.

Return values
bool

◆ get_runtime()

core\task\task_base::get_runtime ( )
inherited

Returns task runtime.

Return values
int

◆ get_runtime_result()

core\task\task_base::get_runtime_result ( )
inherited

Returns if the task has been running for too long.

Return values
result

◆ get_timestarted()

core\task\task_base::get_timestarted ( )
inherited

Getter for $timestarted.

Return values
int

◆ is_blocking()

core\task\task_base::is_blocking ( )
inherited

Getter for $blocking.

Return values
bool

◆ is_component_enabled()

core\task\task_base::is_component_enabled ( )
inherited

Informs whether the task's component is enabled.

Return values
booltrue when enabled. false otherwise.

◆ is_customised()

core\task\scheduled_task::is_customised ( )
inherited

Has this task been changed from it's default config?

Return values
bool

◆ is_enabled()

core\task\scheduled_task::is_enabled ( )
inherited

Checks whether the component and the task disabled flag enables to run this task.

This do not checks whether the task manager allows running them or if the site allows tasks to "run now".

Return values
booltrue if task is enabled. false otherwise.

◆ is_overridden()

core\task\scheduled_task::is_overridden ( )
inherited

Has this task been changed from it's default config?

Return values
bool

◆ is_valid()

core\task\scheduled_task::is_valid ( string $field)
inherited

Informs whether the given field is valid.

Use the constants FIELD_* to identify the field. Have to be called after the method set_{field}(string).

Parameters
string$fieldfield identifier; expected values from constants FIELD_*.
Return values
booltrue if given field is valid. false otherwise.

◆ set_blocking()

core\task\task_base::set_blocking ( $blocking)
inherited

Setter for $blocking.

Parameters
bool$blocking

◆ set_component()

core\task\task_base::set_component ( $component)
inherited

Setter for $component.

Parameters
string$component

◆ set_cron_lock()

core\task\task_base::set_cron_lock ( \core\lock\lock $lock)
inherited

Set the current lock for the entire cron process.

Parameters
core\lock\lock$lock

◆ set_customised()

core\task\scheduled_task::set_customised ( $customised)
inherited

Has this task been changed from it's default config?

Parameters
bool

◆ set_day()

core\task\scheduled_task::set_day ( $day)
inherited

Setter for $day.

Parameters
string$day

◆ set_day_of_week()

core\task\scheduled_task::set_day_of_week ( $dayofweek,
$expandr = true )
inherited

Setter for $dayofweek.

Parameters
string$dayofweek
bool$expandr- if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R'

◆ set_disabled()

core\task\scheduled_task::set_disabled ( $disabled)
inherited

Setter for $disabled.

Parameters
bool$disabled

◆ set_fail_delay()

core\task\task_base::set_fail_delay ( $faildelay)
inherited

Setter for $faildelay.

Parameters
int$faildelay

◆ set_hostname()

core\task\task_base::set_hostname ( $hostname = null)
inherited

Setter for $hostname.

Parameters
string$hostname

◆ set_hour()

core\task\scheduled_task::set_hour ( $hour,
$expandr = true )
inherited

Setter for $hour.

Accepts a special 'R' value which will be translated to a random hour.

Parameters
string$hour
bool$expandr- if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R'

◆ set_last_run_time()

core\task\scheduled_task::set_last_run_time ( $lastruntime)
inherited

Set the last run time for this scheduled task.

Parameters
int$lastruntime

◆ set_lock()

core\task\task_base::set_lock ( \core\lock\lock $lock)
inherited

Set the current lock for this task.

Parameters
core\lock\lock$lock

◆ set_minute()

core\task\scheduled_task::set_minute ( $minute,
$expandr = true )
inherited

Setter for $minute.

Accepts a special 'R' value which will be translated to a random minute.

Parameters
string$minute
bool$expandr- if true (default) an 'R' value in a time is expanded to an appropriate int. If false, they are left as 'R'

◆ set_month()

core\task\scheduled_task::set_month ( $month)
inherited

Setter for $month.

Parameters
string$month

◆ set_next_run_time()

core\task\task_base::set_next_run_time ( $nextruntime)
inherited

Set the next run time for this task.

Parameters
int$nextruntime

◆ set_overridden()

core\task\scheduled_task::set_overridden ( bool $overridden)
inherited

Set the overridden value.

Parameters
bool$overridden

◆ set_pid()

core\task\task_base::set_pid ( $pid = null)
inherited

Setter for $pid.

Parameters
int$pid

◆ set_timestarted()

core\task\task_base::set_timestarted ( $timestarted = null)
inherited

Setter for $timestarted.

Parameters
int$timestarted

Member Data Documentation

◆ NEVER_RUN_TIME

const core\task\scheduled_task::NEVER_RUN_TIME = 7952342400
inherited

Time used for the next scheduled time when a task should never run.

This is 2222-01-01 00:00 GMT which is a large time that still fits in 10 digits.


The documentation for this class was generated from the following file: