Created
February 14, 2014 18:23
-
-
Save miteshmap/9006224 to your computer and use it in GitHub Desktop.
Use of hook_cron_queue_info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Implements hook_Cron_queue_info(). | |
| */ | |
| function foo_cron_queue_info() { | |
| $queues['vehicle_new_queue'] = array( | |
| 'worker callback' => 'vehicle_new_queue_run', | |
| 'time' => 60, | |
| ); | |
| return $queues; | |
| } | |
| /** | |
| * Generate queue for vehicle. | |
| * | |
| * Implements hook_cron(). | |
| */ | |
| function foo_cron() { | |
| //Generate queue for vehicle new to generate trims on cron run. | |
| $queue = DrupalQueue::get('vehicle_new_queue'); | |
| $queue->createQueue(); | |
| // Load all vehicle new node | |
| $nodes = node_load_multiple(array(), array('type' => 'neuf')); | |
| foreach($nodes as $node) { | |
| // add each node to queue to process trims later | |
| $queue->createItem($node); | |
| } | |
| } | |
| /** | |
| * Worker callback of queue. | |
| * @param $data | |
| * $data is queue item | |
| * | |
| * @see vehicle_new_trim_cron_queue_info(). | |
| */ | |
| function vehicle_new_queue_run($data) { | |
| // For this functon $data is node object. | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment