You are here

function feeds_tamper_rectify_instances in Feeds Tamper 7

Removes plugin instances whos source was removed.

Parameters

FeedsImporter $importer: The importer to rectify against.

Related topics

1 call to feeds_tamper_rectify_instances()
feeds_tamper_form_feeds_ui_mapping_form_submit in ./feeds_tamper.inc
Submit callback for feeds_ui_mapping_form().

File

./feeds_tamper.inc, line 103
Version agnostic parts of feeds_tamper.module.

Code

function feeds_tamper_rectify_instances(FeedsImporter $importer) {
  ctools_include('export');
  $instances = ctools_export_load_object('feeds_tamper', 'conditions', array(
    'importer' => $importer->id,
  ));
  $sources = feeds_tamper_get_unique_source_list($importer, FALSE);
  foreach ($instances as $instance) {
    if (in_array($instance->source, $sources)) {
      continue;
    }
    if ($instance->export_type == EXPORT_IN_DATABASE) {
      feeds_tamper_delete_instance($instance);
    }
    else {
      $instance->disabled = TRUE;
      feeds_tamper_save_instance($instance);
    }
  }
}