You are here

function hook_cronapi in Ultimate Cron 7.2

Same name and namespace in other branches
  1. 8.2 ultimate_cron.api.php \hook_cronapi()

Inform Ultimate Cron about cron jobs.

Note that the result of this hook is cached.

Return value

array Array of cron jobs, keyed by name.

  • "title": (optional) The title of the cron job. If not provided, the name of the cron job will be used.
  • "file": (optional) The file where the callback lives.
  • "module": The module where this job lives.
  • "file path": (optional) The path to the directory containing the file specified in "file". This defaults to the path to the module implementing the hook.
  • "callback": (optional) The callback to call when running the job. Defaults to the job name.
  • "callback arguments": (optional) Arguments for the callback. Defaults to array().
  • "enabled": (optional) Initial state of the job. Defaults to TRUE.
  • "tags": (optional) Tags for the job. Defaults to array().
  • "settings": (optional) Default settings (plugin type) for this job. Example of a job declaring some default settings for a plugin called "some_plugin": 'settings' => array( 'some_plugin' => array( 'some_value' => 60, ), ),
  • "scheduler": (optional) Default scheduler (plugin type) for this job. Example of a job using the crontab scheduler as default: 'scheduler' => array( 'name' => 'crontab', 'crontab' => array( 'rules' => array('* * * * *'), ), ),
  • "launcher": (optional) Default launcher (plugin type) for this job. Example of a job using the serial launcher as default: 'launcher' => array( 'name' => 'serial', 'serial' => array( 'thread' => 'any', ), ),
  • "logger": (optional) Default logger (plugin type) for this job. Example of a job using the cache logger as default: 'logger' => array( 'name' => 'cache', 'cache' => array( 'bin' => 'mycachebin', ), ),
1 function implements hook_cronapi()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

ultimate_cron_cronapi in ./ultimate_cron.cron.inc
Implements hook_cronapi().
2 invocations of hook_cronapi()
UltimateCronJob::invoke in ./ultimate_cron.job.inc
Invoke the jobs callback.
ultimate_cron_get_module_hooks in ./ultimate_cron.module
Get cron hooks declared by a module.

File

./ultimate_cron.api.php, line 65
Hooks provided by Ultimate Cron.

Code

function hook_cronapi() {
  $items = array();
  $items['example_my_cron_job_1'] = array(
    'title' => t('This is my cron job #1'),
    'file' => 'example.jobs.inc',
    'file path' => drupal_get_path('module', 'example') . '/cron',
    'callback' => 'example_my_cron_job_callback',
    'callback arguments' => array(
      'cronjob1',
    ),
    'enabled' => FALSE,
    'tags' => array(
      'example',
    ),
    'settings' => array(
      'example_plugin' => array(
        'example_setting' => 'example_value',
      ),
    ),
    'scheduler' => array(
      'name' => 'crontab',
      'crontab' => array(
        'rules' => array(
          '* * * * *',
        ),
      ),
    ),
    'launcher' => array(
      'name' => 'serial',
      'serial' => array(
        'thread' => 'any',
      ),
    ),
    'logger' => array(
      'name' => 'cache',
      'cache' => array(
        'bin' => 'my_cache_bin',
      ),
    ),
  );
  return $items;
}