Skip to content
Snippets Groups Projects
Commit 48b76ced authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Issue #1843146 by twistor: Add pluginType() method to be able to determine the...

Issue #1843146 by twistor: Add pluginType() method to be able to determine the plugin type without having to lookup the inheritance.
parent 1a218359
No related branches found
No related tags found
No related merge requests found
......@@ -136,7 +136,7 @@ abstract class FeedsConfigurable {
}
/**
* Override magic method __get(). Make sure that $this->config goes through
* Override magic method __get(). Make sure that $this->config goes through
* getConfig().
*/
public function __get($name) {
......@@ -265,6 +265,8 @@ function feeds_form_submit($form, &$form_state) {
/**
* Helper for Feeds validate and submit callbacks.
*
* @todo This is all terrible. Remove.
*/
function _feeds_form_helper($form, &$form_state, $action) {
$method = $form['#feeds_form_method'] . $action;
......@@ -277,12 +279,13 @@ function _feeds_form_helper($form, &$form_state, $action) {
// This will re-initialize all of the plugins anyway, causing some tricky
// saving issues in certain cases.
// See http://drupal.org/node/1672880.
if ($class == variable_get('feeds_importer_class', 'FeedsImporter')) {
$form['#configurable'] = feeds_importer($id);
}
else {
$form['#configurable'] = feeds_plugin($class, $id);
$importer = feeds_importer($id);
$plugin_key = $importer->config[$form['#configurable']->pluginType()]['plugin_key'];
$form['#configurable'] = feeds_plugin($plugin_key, $id);
}
if (method_exists($form['#configurable'], $method)) {
......
......@@ -113,6 +113,13 @@ class FeedsFetcherResult extends FeedsResult {
*/
abstract class FeedsFetcher extends FeedsPlugin {
/**
* Implements FeedsPlugin::pluginType().
*/
public static function pluginType() {
return 'fetcher';
}
/**
* Fetch content from a source and return it.
*
......
......@@ -53,6 +53,13 @@ class FeedsParserResult extends FeedsResult {
*/
abstract class FeedsParser extends FeedsPlugin {
/**
* Implements FeedsPlugin::pluginType().
*/
public static function pluginType() {
return 'parser';
}
/**
* Parse content fetched by fetcher.
*
......
......@@ -29,6 +29,14 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
$this->source_config = $this->sourceDefaults();
}
/**
* Returns the type of plugin.
*
* @return string
* One of either 'fetcher', 'parser', or 'processor'.
*/
abstract public static function pluginType();
/**
* Save changes to the configuration of this object.
* Delegate saving to parent (= Feed) which will collect
......
......@@ -28,6 +28,14 @@ class FeedsAccessException extends Exception {}
* Abstract class, defines interface for processors.
*/
abstract class FeedsProcessor extends FeedsPlugin {
/**
* Implements FeedsPlugin::pluginType().
*/
public static function pluginType() {
return 'processor';
}
/**
* @defgroup entity_api_wrapper Entity API wrapper.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment