function content_features_export in Features 6
Implementation of hook_features_export().
File
- includes/
features.content.inc, line 37
Code
function content_features_export($data, &$export, $module_name = '') {
features_include_defaults('content');
$pipe = array();
// The content_default_fields() hook integration is provided by the
// features module so we need to add it as a dependency.
$export['dependencies']['features'] = 'features';
// Collect a field to module map
$map = features_get_default_map('content', NULL, 'content_features_identifier');
foreach ($data as $instance) {
// If this field is already provided by another module remove the field.
// We do not add the other module as a dependency as the field-providing
// module may be extending the content type in question.
if (isset($map[$instance]) && $map[$instance] != $module_name) {
if (isset($export['features']['content'][$instance])) {
unset($export['features']['content'][$instance]);
}
}
else {
$split = explode('-', $instance);
$type_name = $split[0];
$field_name = $split[1];
$field = content_fields($field_name, $type_name);
if (!empty($field)) {
// Add field item instance for later export.
$export['features']['content'][$instance] = $instance;
// Add module which provides field.
$export['dependencies'][$field['module']] = $field['module'];
// Add module which provides field widget.
$export['dependencies'][$field['widget']['module']] = $field['widget']['module'];
// Add modules which provide display.
foreach (array(
'teaser',
'full',
) as $display) {
$formatter = _content_get_formatter($field['display_settings'][$display]['format'], $field['type']);
$export['dependencies'][$formatter['module']] = $formatter['module'];
// TODO make this logic more generic, for now though we just handle
// the imagecache presets.
if ($formatter['module'] == 'imagecache') {
$format = $field['display_settings'][$display]['format'];
$parts = explode('_', $format);
$style = array_pop($parts);
$presetname = implode('_', $parts);
$pipe[$formatter['module']][] = $presetname;
}
}
}
}
}
return $pipe;
}