You are here

function namefield_features_rebuild in Name Field 7

Implements hook_features_export_rebuild().

1 call to namefield_features_rebuild()
namefield_features_revert in includes/name.features.inc
Implements hook_features_revert().

File

includes/name.features.inc, line 69

Code

function namefield_features_rebuild($module) {
  if ($defaults = features_get_default('namefield', $module)) {
    foreach ($defaults as $format) {
      $format = (object) $format;
      if ($format->machine_name == 'default') {
        $settings = name_settings();
        if (!empty($format->default_format)) {
          $settings['default_format'] = $format->default_format;
        }
        foreach (array(
          'sep1',
          'sep2',
          'sep3',
        ) as $key) {
          if (isset($format->{$key})) {
            $settings[$key] = $format->{$key};
          }
        }
        variable_set('name_settings', $settings);
      }
      else {
        if (isset($format->ncfid)) {
          unset($format->ncfid);
        }
        db_merge('name_custom_format')
          ->key(array(
          'machine_name' => $format->machine_name,
        ))
          ->fields(array(
          'name' => $format->name,
          'format' => $format->format,
        ))
          ->execute();
      }
    }
  }
}