You are here

stage_file_proxy.drush.inc in Stage File Proxy 7

Contains drush commands.

File

stage_file_proxy.drush.inc
View source
<?php

/**
 * @file
 * Contains drush commands.
 */

/**
 * Implements hook_drush_command().
 */
function stage_file_proxy_drush_command() {
  $items = array();
  $items['stage-file-proxy-dl'] = array(
    'description' => 'Download all managed files from the origin.',
  );
  return $items;
}

/**
 * Download all managed files from the origin.
 */
function drush_stage_file_proxy_dl() {
  $origin = variable_get('stage_file_proxy_origin');
  if (empty($origin)) {
    drush_print(dt('Configure stage_file_proxy_origin variable in your settings.php.'), 'error');
    return;
  }
  $query = db_select('file_managed', 'fm');
  $query
    ->fields('fm', array(
    'uri',
  ));
  $query
    ->orderBy('fm.fid', 'DESC');
  $results = $query
    ->execute()
    ->fetchCol();
  $got_files_number = 0;
  foreach ($results as $uri) {
    if (stage_file_proxy_process_file_uri($uri)) {
      if (drush_get_option('verbose', FALSE)) {
        drush_print(dt('Downloaded @file.', array(
          '@file' => $uri,
        )));
      }
      $got_files_number++;
    }
  }
  drush_print(dt('@got_files_number downladed files.', array(
    '@got_files_number' => $got_files_number,
  )));
}

Functions

Namesort descending Description
drush_stage_file_proxy_dl Download all managed files from the origin.
stage_file_proxy_drush_command Implements hook_drush_command().