'notifications_drush_queue_process', 'description' => "Process queued notifications and send out messages.", 'arguments' => array( 'rows' => 'Optional maximum number of rows to process. Zero for no limit.', 'messages' => 'Optional maximum number of messages to send. Zero for no limit.', ), ); return $items; } /** * Implementation of hook_drush_help(). */ function notifications_drush_help($section) { switch ($section) { case 'drush:notifications process': return dt("Process queued notifications and send out messages."); } } /** * Drush command callback, process queue * * @param $rows * Maximum number of rows to process */ function notifications_drush_queue_process($rows = NULL, $messages = NULL) { // We need to override autoload_class() so it works with Drush. // The prepend parameter is PHP 5.3 so we better unregister autoload_class() too spl_autoload_register('notifications_drush_autoload_class'); spl_autoload_unregister('autoload_class'); notifications_include('process.inc'); // If passed a time limit we set it before, it will not be overridden by settings. if (isset($rows)) { notifications_process('limit', 'row', (int)$rows); } if (isset($messages)) { notifications_process('limit', 'message', (int)$messages); } $count = notifications_process_run(FALSE); drush_print(dt("Processed @rows rows, sent @messages messages in @time ms.", notifications_process('results'))); } /** * Autoload hack, so autoload paths work with drush */ function notifications_drush_autoload_class($class) { static $lookup; if (!isset($lookup)) { $lookup = autoload_get_lookup(); } if (!empty($lookup[$class]) && ($path = realpath($lookup[$class]))) { require $path; } }