public function PreviewLinkHooks::cron in Preview Link 8
Implements hook_cron().
See also
File
- src/
PreviewLinkHooks.php, line 67
Class
- PreviewLinkHooks
- Drupal hooks.
Namespace
Drupal\preview_linkCode
public function cron() {
$expireBeforeTime = $this->time
->getRequestTime() - $this->linkExpiry
->getLifetime();
$ids = $this->previewLinkStorage
->getQuery()
->condition('generated_timestamp', $expireBeforeTime, '<')
->execute();
// If there are no expired links then nothing to do.
if (!count($ids)) {
return;
}
$previewLinks = $this->previewLinkStorage
->loadMultiple($ids);
// Simply delete the preview links. A new one will be regenerated at a later
// date as required.
$this->previewLinkStorage
->delete($previewLinks);
}