You are here

function textimage_cron in Textimage 8.3

Same name and namespace in other branches
  1. 8.4 textimage.module \textimage_cron()
  2. 7.3 textimage.module \textimage_cron()

Implements hook_cron().

File

./textimage.module, line 91
Textimage - Provides text to image manipulations.

Code

function textimage_cron() {

  // Remove temporary, uncached, image files in all available schemes.
  $wrappers = \Drupal::service('stream_wrapper_manager')
    ->getWrappers(StreamWrapperInterface::WRITE_VISIBLE);
  foreach ($wrappers as $wrapper => $wrapper_data) {
    if (file_exists($directory = \Drupal::service('textimage.factory')
      ->getStoreUri('/temp', $wrapper))) {
      if (file_unmanaged_delete_recursive($directory)) {
        \Drupal::service('textimage.logger')
          ->notice('Textimage temporary image files removed.');
      }
      else {
        \Drupal::service('textimage.logger')
          ->error('Textimage could not remove temporary image files.');
      }
    }
  }
}