Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/cron.twig
vendored
Normal file
34
vendor/chi-teck/drupal-code-generator/templates/d8/hook/cron.twig
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Implements hook_cron().
|
||||
*/
|
||||
function {{ machine_name }}_cron() {
|
||||
// Short-running operation example, not using a queue:
|
||||
// Delete all expired records since the last cron run.
|
||||
$expires = \Drupal::state()->get('mymodule.last_check', 0);
|
||||
\Drupal::database()->delete('mymodule_table')
|
||||
->condition('expires', $expires, '>=')
|
||||
->execute();
|
||||
\Drupal::state()->set('mymodule.last_check', REQUEST_TIME);
|
||||
|
||||
// Long-running operation example, leveraging a queue:
|
||||
// Queue news feeds for updates once their refresh interval has elapsed.
|
||||
$queue = \Drupal::queue('aggregator_feeds');
|
||||
$ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh();
|
||||
foreach (Feed::loadMultiple($ids) as $feed) {
|
||||
if ($queue->createItem($feed)) {
|
||||
// Add timestamp to avoid queueing item more than once.
|
||||
$feed->setQueuedTime(REQUEST_TIME);
|
||||
$feed->save();
|
||||
}
|
||||
}
|
||||
$ids = \Drupal::entityQuery('aggregator_feed')
|
||||
->condition('queued', REQUEST_TIME - (3600 * 6), '<')
|
||||
->execute();
|
||||
if ($ids) {
|
||||
$feeds = Feed::loadMultiple($ids);
|
||||
foreach ($feeds as $feed) {
|
||||
$feed->setQueuedTime(0);
|
||||
$feed->save();
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue