You are here

function FeedImportController::processFeed in Feed Import 8

Process a feed

Parameters

string $feed: Feed machine name

1 string reference to 'FeedImportController::processFeed'
feed_import.routing.yml in ./feed_import.routing.yml
feed_import.routing.yml

File

src/Controller/FeedImportController.php, line 60
Contains \Drupal\feed_import\Controller\FeedImportController.

Class

FeedImportController
Controller routines for feed_import routes.

Namespace

Drupal\feed_import\Controller

Code

function processFeed($fid) {
  $feed = FeedImport::loadFeed($fid);
  $status = _feed_import_base_process_feed($feed, TRUE);
  switch ($status) {
    case FeedImport::FEED_OK:
      drupal_set_message(t('Feed @name processed!', array(
        '@name' => $feed->name,
      )));
      break;
    case FeedImport::FEED_OVERLAP_ERR:
      drupal_set_message(t('Cannot process feed because another one is running!'), 'error');
      break;
    case FeedImport::FEED_CONFIG_ERR:
      drupal_set_message(t('Cannot process feed because source is misconfigured!'), 'error');
      break;
    case FeedImport::FEED_SOURCE_ERR:
      drupal_set_message(t('Cannot process feed because there is a source error!'), 'error');
      drupal_set_message(t('All items were rescheduled due to delete protection!'), 'warning');
      break;
    case FeedImport::FEED_ITEMS_ERR:
      drupal_set_message(t('Feed @name processed!', array(
        '@name' => $feed->name,
      )));
      drupal_set_message(t('All items were rescheduled due to delete protection!'), 'warning');
      break;
  }
  return $this
    ->redirect('feed_import.admin');
}