You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

See also: Writing Registry Plugins

Some additional conventions are required when writing a Job Plugin.

  1. The name of the Plugin should match the format FooJob. The prefix (eg: Foo) will be used as the job_type in cm_co_jobs.
  2. The Plugin must implement two functions, which are defined in Model/FooJob.php.
    1. 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.
      1. When the Job is started, it should call $CoJob->update() (with appropriate arguments).
      2. When executing, the Job should not typically generate output, but should instead create Job History records. If it is absolutely necessary to write to stdout, the Job should follow Cake's Console output levels.
      3. If the Job loops over multiple records, it should check $CoJob->canceled($jobid) after each iteration, and immediately terminate processing if the Job has been canceled.
      4. When complete, the Job must call $CoJob->finish(), with appropriate arguments. (The Job will be set to started when dispatched, before the Plugin is invoked.)
    2. 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:
      1. choices: An array of permitted values for the parameter (when type is select)
      2. help: Help text for the parameter
      3. required: Boolean indicating whether or not this parameter is required
      4. type: One of int, select, or string.
  • No labels