Projet

Général

Profil

Paste
Télécharger (1,42 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / job_scheduler / job_scheduler.api.php @ 87dbc3bf

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
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
 *
20
 * @see hook_cron_job_scheduler_info_alter()
21
 * @see hook_cron_queue_info()
22
 * @see hook_cron_queue_info_alter()
23
 */
24
function hook_cron_job_scheduler_info() {
25
  $info = array();
26
  $info['example_reset'] = array(
27
    'worker callback' => 'example_cache_clear_worker',
28
  );
29
  $info['example_import'] = array(
30
    'queue name' => 'example_import_queue',
31
  );
32
  return $info;
33
}
34

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