Skip to content
Snippets Groups Projects
Commit 79918b8f authored by twistor's avatar twistor Committed by Chris Leppanen
Browse files

Issue #2497507 by twistor: Pass plugin definition to FeedsPlugin objects

parent ef104d07
No related branches found
No related tags found
No related merge requests found
...@@ -29,14 +29,16 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter ...@@ -29,14 +29,16 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
/** /**
* Constructs a FeedsPlugin object. * Constructs a FeedsPlugin object.
* *
* A copy of FeedsConfigurable::__construct() that doesn't call
* configDefaults() so that we avoid circular dependencies.
*
* @param string $id * @param string $id
* The plugin id. * The importer id.
* @param array $plugin_definition
* The plugin definition.
*/ */
protected function __construct($id, array $plugin_definition) { protected function __construct($id) {
$this->pluginDefinition = $plugin_definition; $this->id = $id;
parent::__construct($id); $this->export_type = FEEDS_EXPORT_NONE;
$this->disabled = FALSE;
} }
/** /**
...@@ -54,7 +56,13 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter ...@@ -54,7 +56,13 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
static $instances = array(); static $instances = array();
if (!isset($instances[$class][$id])) { if (!isset($instances[$class][$id])) {
$instances[$class][$id] = new $class($id, $plugin_definition); $instance = new $class($id);
// The ordering here is important. The plugin definition should be usable
// in getConfig().
$instance->setPluginDefinition($plugin_definition);
$instance->setConfig($instance->configDefaults());
$instances[$class][$id] = $instance;
} }
return $instances[$class][$id]; return $instances[$class][$id];
...@@ -80,6 +88,18 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter ...@@ -80,6 +88,18 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
return $this->pluginDefinition; return $this->pluginDefinition;
} }
/**
* Sets the plugin definition.
*
* This is protected since we're only using it in FeedsPlugin::instance().
*
* @param array $plugin_definition
* The plugin definition.
*/
protected function setPluginDefinition(array $plugin_definition) {
$this->pluginDefinition = $plugin_definition;
}
/** /**
* Save changes to the configuration of this object. * Save changes to the configuration of this object.
* Delegate saving to parent (= Feed) which will collect * Delegate saving to parent (= Feed) which will collect
......
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