You are here

function fieldgroup_features_export in Features 6

Implementation of hook_features_export().

File

includes/features.fieldgroup.inc, line 19

Code

function fieldgroup_features_export($data, &$export, $module_name = '') {
  features_include_defaults('fieldgroup');
  $pipe = array();

  // The hook_fieldgroup_default_groups() hook integration is provided by the
  // features module so we need to add it as a dependency.
  $export['dependencies']['features'] = 'features';

  // Collect a group to module map
  $map = features_get_default_map('fieldgroup', NULL, 'fieldgroup_features_identifier');
  foreach ($data as $instance) {

    // If this group is already provided by another module remove the group.
    // We do not add the other module as a dependency as the group-providing
    // module may be extending the content type in question.
    if (isset($map[$instance]) && $map[$instance] != $module_name) {
      if (isset($export['features']['fieldgroup'][$instance])) {
        unset($export['features']['fieldgroup'][$instance]);
      }
    }
    else {
      $split = explode('-', $instance);
      $type_name = $split[0];
      $group_name = $split[1];
      $groups = fieldgroup_groups($type_name, FALSE, TRUE);
      if (isset($groups[$group_name]) && ($group = $groups[$group_name])) {
        $export['features']['fieldgroup'][$instance] = $instance;
        $export['dependencies']['fieldgroup'] = 'fieldgroup';
      }
    }
  }
  return $pipe;
}