Scheduled Tasks

Plugins

A set of tasks can be registered with the Cron component by making a plugin. Each plugin must respond to the "onCronEvents" trigger. The response from that trigger is an object (stdClass) that returns the plugin's name and an array of callable tasks (event triggers).

Registering Tasks

Plugins should be placed within the cron plugins folder:

/app
.. /plugins
.. .. /cron

Here is an example of a cron plugin that registers a set of "mytasks" events.

As shown in the previous example, each event consist of an array containing three keys: name, label, and params.

name

The plugin must implement a method with the same name as whatever is specified for the name key and the names should match exactly. That is, if a name of 'onJumpUpAndDown' is specified, then the plugin must have a method of onJumpUpAndDown();.

label

This is a nice, human readable name for the event trigger. It should be a language key with an associated string in the plugin's language file.

params

This is an optional value for specifying a params group (Joomla 1.5) or fieldset (Joomla 1.6+) containing parameters associated with the specific plugin event. This allows for multiple cron jobs calling the same event but with varying values. An example of this can be found in the support tickets cron plugin where the event sendTicketsReminder has a specified params group of 'ticketreminder'. Changing those params would allow, for instance, a job that sends ticket reminders one a month for all open tickets and a ticket reminder once a week for all open and status: critical tickets.

A snippet from the support plugin, specifying the list of available tasks: