NAME
MT::Task - Movable Type class for registering runnable tasks.
SYNOPSIS
package MyPlugin;
MT->add_task(new MT::Task({
name => "My Task",
key => "Task001",
frequency => 360, # at most, once per hour
code => \&runner
}));
DESCRIPTION
An MT::Task object is used to define a runnable task that can be executed by Movable Type. The base object defines common characteristics of all tasks as well as the method to invoke it.
Normally, a plugin will construct an MT::Task object and pass it to the add_task method of the MT class:
MT->add_task(new MT::Task({
# arguments; see listing of arguments below
}));
ARGUMENTS
The following are a list of parameters that can be specified when constructing an MT::Task object.
- key
- name
- frequency
- code
Defines a unique string for the task. This is used to manage a session record for the task. The task session record is kept to record the last time the task was executed. Session records are stored in the mt_session table with a 'kind' column value of 'PT' (periodic task).
The name of the task. This is optional, but is used in recording error log records when the task fails.
The frequency is a duration of time expressed in seconds. This defines how often the task is to be run. There is no guarantee that the task will be run this often; only that it will not be executed more than once for that period of time.
The code to be executed when the task is invoked by MT::TaskMgr. This is a code reference and the routine is given the MT::Task instance as a parameter.
AUTHOR & COPYRIGHTS
Please see the MT manpage for author, copyright, and license information.
