You are here

public function FeedsImporter::setPlugin in Feeds 8.2

Set plugin.

@todo Error handling, handle setting to the same plugin.

Parameters

$plugin_key: A fetcher, parser or processor plugin.

1 call to FeedsImporter::setPlugin()
FeedsImporter::copy in lib/Drupal/feeds/FeedsImporter.php
Copy a FeedsImporter configuration into this importer.

File

lib/Drupal/feeds/FeedsImporter.php, line 127
FeedsImporter class and related.

Class

FeedsImporter
A FeedsImporter object describes how an external source should be fetched, parsed and processed. Feeds can manage an arbitrary amount of importers.

Namespace

Drupal\feeds

Code

public function setPlugin($plugin_key) {

  // $plugin_type can be either 'fetcher', 'parser' or 'processor'
  if ($plugin_type = FeedsPlugin::typeOf($plugin_key)) {
    if ($plugin = feeds_plugin($plugin_key, $this->id)) {

      // Unset existing plugin, switch to new plugin.
      unset($this->{$plugin_type});
      $this->{$plugin_type} = $plugin;

      // Set configuration information, blow away any previous information on
      // this spot.
      $this->config[$plugin_type] = array(
        'plugin_key' => $plugin_key,
      );
    }
  }
}