You are here

function feeds_plugin_instance in Feeds 6

Gets an instance of a class for a given plugin and id.

Parameters

$plugin: A string that is the key of the plugin to load.

$id: A string that is the id of the object.

Return value

A FeedsPlugin object.

Throws

Exception If plugin can't be instantiated.

Related topics

4 calls to feeds_plugin_instance()
FeedsDateTimeTest::setUp in tests/feeds_date_time.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
FeedsImporter::setPlugin in includes/FeedsImporter.inc
Set plugin.
FeedsImporter::__construct in includes/FeedsImporter.inc
Instantiate class variables, initialize and configure plugins.
feeds_ui_edit_page in feeds_ui/feeds_ui.admin.inc
Edit feed configuration.

File

./feeds.module, line 804
Feeds - basic API functions and hook implementations.

Code

function feeds_plugin_instance($plugin, $id) {
  feeds_include('FeedsImporter');
  ctools_include('plugins');
  if ($class = ctools_plugin_load_class('feeds', 'plugins', $plugin, 'handler')) {
    return FeedsConfigurable::instance($class, $id);
  }
  $args = array(
    '%plugin' => $plugin,
    '@id' => $id,
  );
  if (user_access('administer feeds')) {
    $args['@link'] = url('admin/build/feeds/edit/' . $id);
    drupal_set_message(t('Missing Feeds plugin %plugin. See <a href="@link">@id</a>. Check whether all required libraries and modules are installed properly.', $args), 'warning', FALSE);
  }
  else {
    drupal_set_message(t('Missing Feeds plugin %plugin. Please contact your site administrator.', $args), 'warning', FALSE);
  }
  $class = ctools_plugin_load_class('feeds', 'plugins', 'FeedsMissingPlugin', 'handler');
  return FeedsConfigurable::instance($class, $id);
}