You are here

public static function FeedImport::import in Feed Import 8

Imports a feed.

Parameters

object $feed: Feed info

string $filters_dir: Path to filters dir

1 call to FeedImport::import()
_feed_import_base_process_feed in feed_import_base/feed_import_base.module
Imports a feed.

File

feed_import_base/src/FeedImport.php, line 402

Class

FeedImport
This class provides helper functions for feed import.

Namespace

Drupal\feed_import_base

Code

public static function import($feed, $filters_dir) {
  if (!empty($feed->settings['preprocess']) && function_exists($feed->settings['preprocess'])) {

    // Preprocess feed before import.
    call_user_func($feed->settings['preprocess'], $feed);
  }
  $class = $feed->settings['processor']['class'];
  $fi = new $class($feed->machine_name);
  $fi
    ->setErrorHandler(TRUE);
  $f = static::setProcessorSettings($fi, $feed, $filters_dir);
  if ($f !== TRUE) {
    $fi
      ->setErrorHandler(FALSE);
    return array(
      'init_error' => TRUE,
      'errors' => $f,
    );
  }
  unset($f);
  $lastimport = static::$activeImport;
  static::$activeImport = $fi;
  $f = $fi
    ->process();
  static::$activeImport = $lastimport;
  $fi
    ->setErrorHandler(FALSE);
  return $f;
}