function AnnouncementsFeedCronHooks::cron
Same name and namespace in other branches
- 11.x core/modules/announcements_feed/src/Hook/AnnouncementsFeedCronHooks.php \Drupal\announcements_feed\Hook\AnnouncementsFeedCronHooks::cron()
Implements hook_cron().
Attributes
File
-
core/
modules/ announcements_feed/ src/ Hook/ AnnouncementsFeedCronHooks.php, line 26
Class
- AnnouncementsFeedCronHooks
- Cron hook implementations for announcements_feed.
Namespace
Drupal\announcements_feed\HookCode
public function cron() : void {
$interval = $this->configFactory
->get('announcements_feed.settings')
->get('cron_interval');
$store = $this->keyValueFactory
->get('announcements_feed');
$last_check = (int) $store->get('last_fetch', 0);
$time = $this->time
->getRequestTime();
if ($time - $last_check > $interval) {
$this->announceFetcher
->fetch(TRUE);
$store->set('last_fetch', $time);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.