Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / cron.twig
1 /**
2  * Implements hook_cron().
3  */
4 function {{ machine_name }}_cron() {
5   // Short-running operation example, not using a queue:
6   // Delete all expired records since the last cron run.
7   $expires = variable_get('mymodule_cron_last_run', REQUEST_TIME);
8   db_delete('mymodule_table')
9     ->condition('expires', $expires, '>=')
10     ->execute();
11   variable_set('mymodule_cron_last_run', REQUEST_TIME);
12
13   // Long-running operation example, leveraging a queue:
14   // Fetch feeds from other sites.
15   $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh <> :never', array(
16     ':time' => REQUEST_TIME,
17     ':never' => AGGREGATOR_CLEAR_NEVER,
18   ));
19   $queue = DrupalQueue::get('aggregator_feeds');
20   foreach ($result as $feed) {
21     $queue->createItem($feed);
22   }
23 }