diff --git a/features.export.inc b/features.export.inc index 19a5b4e..da7276d 100644 --- a/features.export.inc +++ b/features.export.inc @@ -43,7 +43,9 @@ function features_populate($items, $dependencies, $module_name) { function _features_populate($pipe, &$export, $module_name = '') { features_include(); foreach ($pipe as $component => $data) { - if ($function = features_hook($component, 'features_export')) { + // Turn anything to dependencies if already defined + _features_resolve_dependencies($data, $export, $module_name, $component); + if ($data && $function = features_hook($component, 'features_export')) { // Pass module-specific data and export array. // We don't use features_invoke() here since we need to pass $export by reference. $more = $function($data, $export, $module_name, $component); @@ -59,6 +61,22 @@ function _features_populate($pipe, &$export, $module_name = '') { } /** + * Iterates over data and transfer them to depenencies elsewhere if already + * defined elsewhere. + */ +function _features_resolve_dependencies(&$data, &$export, $module_name, $component) { + if ($map = features_get_default_map($component)) { + foreach ($data as $key => $item) { + // If this node type is provided by a different module, add it as a dependency + if (isset($map[$item]) && $map[$item] != $module_name) { + $export['dependencies'][$map[$item]] = $map[$item]; + unset($data[$key]); + } + } + } +} + +/** * Iterates over a list of dependencies and kills modules that are * captured by other modules 'higher up'. */