You are here

function photos_cron in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 photos.module \photos_cron()
  2. 6.2 photos.module \photos_cron()
  3. 7.3 photos.module \photos_cron()
  4. 6.0.x photos.module \photos_cron()

Implements hook_cron().

File

./photos.module, line 1298
Implementation of photos.module.

Code

function photos_cron() {

  // Update photos count.
  PhotosAlbum::resetCount(1);

  // Delete temporary private image styles.
  if (\Drupal::config('photos.settings')
    ->get('photos_private_file_styles') == 'automatic') {

    // @todo set duration e.g. 1 month / week / day?
    if (file_exists('private://photos/tmp_images')) {
      try {
        \Drupal::service('file_system')
          ->deleteRecursive('private://photos/tmp_images');

        // @todo add new photos-album-private cache tag and invalidate here.
      } catch (FileException $e) {
        watchdog_exception('photos', $e);
      }
    }
  }
}