You are here

function instagram_feeds_batch_import in Instagram Feeds 7

Batch API worker callback.

Parameters

array $urls: An array of URLs to import.

array $context: Batch context.

1 string reference to 'instagram_feeds_batch_import'
instagram_feeds_import_tab_form_submit in includes/instagram_feeds.pages.inc
Submit handler for instagram_feeds_import_tab_form().

File

./instagram_feeds.module, line 1214

Code

function instagram_feeds_batch_import(array $urls, &$context) {
  $existing_feeds = instagram_feeds_get_existing_feeds();
  foreach ($urls as $url) {
    if (isset($existing_feeds[$url]->feed_nid)) {
      $tmp = str_replace(INSTAGRAM_FEEDS_BASE_URL . '/', '', $url);
      $url_parts = explode('/', $tmp);
      $type = 'users' == $url_parts[0] ? 'user' : 'tag';
      $context['message'] = t('Importing data for %type %value.', array(
        '%type' => $type,
        '%value' => $url_parts[1],
      ));
      try {
        $context['finished'] = feeds_source(INSTAGRAM_FEEDS_FEED_ID, $existing_feeds[$url]->feed_nid)
          ->import();
      } catch (Exception $e) {
        drupal_set_message($e
          ->getMessage(), 'error');
      }
    }
  }
}