See also:
Some additional conventions are required when writing a Job Plugin.
FooJob
.Foo
) will be used as the job_type
in cm_co_jobs.FooJob
naming convention for the Plugin itself. This enables polymorphic Plugins. ie: Other types of Plugins can also implement Jobs.FooJob
(in Model/FooJob.php
), where Foo matches the name of the Plugin.BarJob
, where Bar may be any string.job_type
in cm_co_jobs is the desired plugin Job model in Cake notation, but without the Job suffix, eg: FooJob.Bar
.CoJobBackend
, which defines some standard interfaces and provides some behind the scenes common functionality.execute($coId, $CoJob, $params)
, which will be passed the relevant CO ID, a CoJob object, and an (optional) array of parameters in accordance with the Plugin's configuration.$CoJob->update()
(with appropriate arguments).$CoJob->canceled($jobid)
after each iteration, and immediately terminate processing if the Job has been canceled.$CoJob->setPercentComplete($jobid, $percent)
at appropriate points during processing.$CoJob->finish()
, with appropriate arguments. (The Job will be set to started when dispatched, before the Plugin is invoked.)parameterFormat()
, which returns an array of parameters supported by the plugin. Each entry in the array has a key of the parameter name and a value of an array with the following keys:choices
: An array of permitted values for the parameter (when type
is select
)help
: Help text for the parameterrequired
: Boolean indicating whether or not this parameter is requiredtype
: One of int
, select
, or string
.Job Plugins, including any code they call, should be careful not to trigger session creation, since sessions in a shell or cron context do not necessarily make sense. If code is mixed use (ie: may also be called from the UI), be sure to check that the session has been created before trying to read from it.
|