You are here

function ultimate_cron_cronapi in Ultimate Cron 7.2

Same name and namespace in other branches
  1. 8 ultimate_cron.module \ultimate_cron_cronapi()
  2. 6 ultimate_cron.module \ultimate_cron_cronapi()
  3. 7 ultimate_cron.module \ultimate_cron_cronapi()

Implements hook_cronapi().

Adds clean up jobs for plugins.

File

./ultimate_cron.cron.inc, line 12
Cron hook implementations for Ultimate Cron.

Code

function ultimate_cron_cronapi() {
  $items = array();
  ctools_include('plugins');
  $plugin_types = ctools_plugin_get_plugin_type_info();
  foreach ($plugin_types['ultimate_cron'] as $plugin_type => $info) {
    foreach (_ultimate_cron_plugin_load_all($plugin_type) as $name => $plugin) {
      if ($plugin
        ->isValid() && method_exists($plugin, 'cleanup')) {
        $items["ultimate_cron_plugin_{$plugin_type}_{$name}_cleanup"] = array(
          'title' => t('Ultimate Cron @type @title cleanup', array(
            '@type' => $info['defaults']['static']['title singular proper'],
            '@title' => $plugin->title,
          )),
          'callback' => 'ultimate_cron_plugin_cleanup',
          'callback arguments' => array(
            'type' => $plugin_type,
            'name' => $name,
          ),
        );
      }
    }
  }
  return $items;
}