job_scheduler.api.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @file
  4. * API documentation for hooks.
  5. */
  6. /**
  7. * Declare job scheduling holding items that need to be run periodically.
  8. *
  9. * @return
  10. * An associative array where the key is the queue name and the value is
  11. * again an associative array. Possible keys are:
  12. * - 'worker callback': The name of the function to call. It will be called
  13. * at schedule time.
  14. * - 'queue name': The name of the queue to use to queue this task. Must
  15. * contain a valid queue name, declared by hook_cron_queue_info().
  16. * If queue name is given, worker callback will be ignored.
  17. *
  18. * @see hook_cron_job_scheduler_info_alter()
  19. * @see hook_cron_queue_info()
  20. * @see hook_cron_queue_info_alter()
  21. */
  22. function hook_cron_job_scheduler_info() {
  23. $info = array();
  24. $info['example_reset'] = array(
  25. 'worker callback' => 'example_cache_clear_worker',
  26. );
  27. $info['example_import'] = array(
  28. 'queue name' => 'example_import_queue',
  29. );
  30. return $info;
  31. }
  32. /**
  33. * Alter cron queue information before cron runs.
  34. *
  35. * Called by drupal_cron_run() to allow modules to alter cron queue settings
  36. * before any jobs are processesed.
  37. *
  38. * @param array $info
  39. * An array of cron schedule information.
  40. *
  41. * @see hook_cron_queue_info()
  42. * @see drupal_cron_run()
  43. */
  44. function hook_cron_job_scheduler_info_alter(&$info) {
  45. // Replace the default callback 'example_cache_clear_worker'
  46. $info['example_reset']['worker callback'] = 'my_custom_reset';
  47. }