You are here

function fontyourface_fyf_import in @font-your-face 7.2

Callback for Drush command 'fyf-import'.

1 string reference to 'fontyourface_fyf_import'
fontyourface_drush_command in drush/fontyourface.drush.inc
Implements hook_drush_command().

File

drush/fontyourface.drush.inc, line 110
Drush integration for @font-your-face.

Code

function fontyourface_fyf_import() {
  $providers = _convert_csv_to_array(func_get_args());
  if (empty($providers)) {

    // If no providers were specified, get all existing import functions.
    $providers = module_implements('fontyourface_import');
  }
  foreach ($providers as $provider) {
    $import_function = $provider . '_fontyourface_import';
    if ($provider == 'fontsquirrel') {
      drush_set_error(dt("Font Squirrel import is not supported yet. We're working on that."));
    }
    elseif (!function_exists($import_function)) {
      drush_set_error(dt("Unknown provider '@provider', or there is no import function for it; run 'drush fyf-status' to see enabled providers", array(
        '@provider' => $provider,
      )));
    }
    else {
      $before = fontyourface_count_fonts($provider);
      if ($import_function()) {
        $message = dt('Imported fonts from @provider.', array(
          '@provider' => $provider,
        ));
        drush_log($message, 'success');
        $after = fontyourface_count_fonts($provider);
        drush_print(dt('@provider now has @fonts fonts (+@diff).', array(
          '@provider' => $provider,
          '@fonts' => $after,
          '@diff' => $after - $before,
        )));
      }
      else {
        drush_set_error(dt('Font import from @provider failed.', array(
          '@provider' => $provider,
        )));
      }
    }
  }
}