Skip to content
Snippets Groups Projects
Commit c3b712d1 authored by megachriz's avatar megachriz Committed by Chris Leppanen
Browse files

Issue #2387419 by MegaChriz: Auto detect dependencies when putting Feeds importer in a feature

parent 6df34638
No related branches found
No related tags found
No related merge requests found
...@@ -720,6 +720,18 @@ function feeds_field_extra_fields() { ...@@ -720,6 +720,18 @@ function feeds_field_extra_fields() {
return $extras; return $extras;
} }
/**
* Implements hook_features_pipe_COMPONENT_alter() for component "feeds_importer".
*
* Automatically adds dependencies when a Feed importer is selected in Features.
*/
function feeds_features_pipe_feeds_importer_alter(&$pipe, $data, &$export) {
foreach ($data as $importer_id) {
if ($importer = feeds_importer_load($importer_id)) {
$export['dependencies'] = array_merge($export['dependencies'], $importer->dependencies());
}
}
}
/** /**
* Implements hook_system_info_alter(). * Implements hook_system_info_alter().
......
...@@ -214,6 +214,16 @@ abstract class FeedsConfigurable { ...@@ -214,6 +214,16 @@ abstract class FeedsConfigurable {
drupal_set_message(t('Your changes have been saved.')); drupal_set_message(t('Your changes have been saved.'));
feeds_cache_clear(FALSE); feeds_cache_clear(FALSE);
} }
/**
* Returns an array of required modules.
*
* @return array
* The modules that this configurable requires.
*/
public function dependencies() {
return array();
}
} }
/** /**
......
...@@ -271,6 +271,17 @@ class FeedsImporter extends FeedsConfigurable { ...@@ -271,6 +271,17 @@ class FeedsImporter extends FeedsConfigurable {
} }
parent::configFormSubmit($values); parent::configFormSubmit($values);
} }
/**
* Implements FeedsConfigurable::dependencies().
*/
public function dependencies() {
$dependencies = parent::dependencies();
foreach ($this->plugin_types as $plugin_type) {
$dependencies = array_merge($dependencies, $this->$plugin_type->dependencies());
}
return $dependencies;
}
} }
/** /**
......
...@@ -799,4 +799,12 @@ class FeedsSource extends FeedsConfigurable { ...@@ -799,4 +799,12 @@ class FeedsSource extends FeedsConfigurable {
lock_release("feeds_source_{$this->id}_{$this->feed_nid}"); lock_release("feeds_source_{$this->id}_{$this->feed_nid}");
} }
/**
* Implements FeedsConfigurable::dependencies().
*/
public function dependencies() {
$dependencies = parent::dependencies();
return array_merge($dependencies, $this->importer()->dependencies());
}
} }
...@@ -209,6 +209,21 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter ...@@ -209,6 +209,21 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
} }
return $result; return $result;
} }
/**
* Implements FeedsConfigurable::dependencies().
*/
public function dependencies() {
$dependencies = parent::dependencies();
// Find out which module provides this plugin.
$plugin_info = $this->pluginDefinition();
if (isset($plugin_info['module'])) {
$dependencies[$plugin_info['module']] = $plugin_info['module'];
}
return $dependencies;
}
} }
/** /**
......
...@@ -1012,6 +1012,21 @@ abstract class FeedsProcessor extends FeedsPlugin { ...@@ -1012,6 +1012,21 @@ abstract class FeedsProcessor extends FeedsPlugin {
return $message; return $message;
} }
/**
* Overrides FeedsPlugin::dependencies().
*/
public function dependencies() {
$dependencies = parent::dependencies();
// Find out which module defined the entity type.
$info = $this->entityInfo();
if (isset($info['module'])) {
$dependencies[$info['module']] = $info['module'];
}
return $dependencies;
}
} }
class FeedsProcessorBundleNotDefined extends Exception {} class FeedsProcessorBundleNotDefined extends Exception {}
...@@ -224,4 +224,14 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -224,4 +224,14 @@ class FeedsTermProcessor extends FeedsProcessor {
} }
throw new Exception(t('No vocabulary defined for Taxonomy Term processor.')); throw new Exception(t('No vocabulary defined for Taxonomy Term processor.'));
} }
/**
* Overrides FeedsProcessor::dependencies().
*/
public function dependencies() {
$dependencies = parent::dependencies();
$dependencies['taxonomy'] = 'taxonomy';
return $dependencies;
}
} }
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