static public function TripalImporter::byID

3.x TripalImporter.inc static public TripalImporter::byID($import_id)

Instantiates a new TripalImporter object using the import record ID.

This function will automatically instantiate the correct TripalImporter child class that is appropriate for the provided ID.

Parameters

$import_id: The ID of the import recrod.

Return value

An TripalImporter object of the appropriate child class.

1 call to TripalImporter::byID()
tripal_run_importer in tripal/api/tripal.importer.api.inc
Imports data into the database.

File

tripal/includes/TripalImporter.inc, line 209

Class

TripalImporter

Code

static public function byID($import_id) {
  // Get the importer.
  $import = db_select('tripal_import', 'ti')
    ->fields('ti')
    ->condition('ti.import_id', $import_id)
    ->execute()
    ->fetchObject();

  if (!$import) {
    throw new Exception('Cannot find an importer that matches the given import ID.');
  }

  $class = $import->class;
  tripal_load_include_importer_class($class);
  if (class_exists($class)) {
    $loader = new $class();
    $loader->load($import_id);
    return $loader;
  }
  else {
    throw new Exception('Cannot find the matching class for this import record.');
  }
}