Project

General

Profile

Paste
Download (1.7 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / job_scheduler / job_scheduler.api.php @ 082b75eb

1
<?php
2

    
3
/**
4
 * @file
5
 * API documentation for hooks.
6
 */
7

    
8
/**
9
 * Declare job scheduling holding items that need to be run periodically.
10
 *
11
 * @return array
12
 *   An associative array where the key is the queue name and the value is
13
 *   again an associative array. Possible keys are:
14
 *   - 'worker callback': The name of the function to call. It will be called
15
 *     at schedule time.
16
 *   - 'queue name': The name of the queue to use to queue this task. Must
17
 *     contain a valid queue name, declared by hook_cron_queue_info().
18
 *   If queue name is given, worker callback will be ignored.
19
 *   - 'jobs': (optional) An array defining jobs for this scheduler. The key is
20
 *     immaterial. Each job item is itself a job array, whose properties should
21
 *     be the same as the parameter to JobScheduler::set().
22
 *
23
 * @see hook_cron_job_scheduler_info_alter()
24
 * @see hook_cron_queue_info()
25
 * @see hook_cron_queue_info_alter()
26
 */
27
function hook_cron_job_scheduler_info() {
28
  $info = array();
29
  $info['example_reset'] = array(
30
    'worker callback' => 'example_cache_clear_worker',
31
  );
32
  $info['example_import'] = array(
33
    'queue name' => 'example_import_queue',
34
  );
35
  return $info;
36
}
37

    
38
/**
39
 * Alter cron queue information before cron runs.
40
 *
41
 * Called by drupal_cron_run() to allow modules to alter cron queue settings
42
 * before any jobs are processesed.
43
 *
44
 * @param array $info
45
 *   An array of cron schedule information.
46
 *
47
 * @see hook_cron_queue_info()
48
 * @see drupal_cron_run()
49
 *
50
 * @codingStandardsIgnoreStart
51
 */
52
function hook_cron_job_scheduler_info_alter(&$info) {
53
  // @codingStandardsIgnoreEnd
54
  // Replace the default callback 'example_cache_clear_worker'.
55
  $info['example_reset']['worker callback'] = 'my_custom_reset';
56
}