function field_configuration_rebuild in Configuration Management 7
Implements of hook_configuration_rebuild(). Rebuilds fields from code defaults.
1 call to field_configuration_rebuild()
- field_configuration_revert in includes/
configuration.field.inc - Implements hook_configuration_revert().
File
- includes/
configuration.field.inc, line 167
Code
function field_configuration_rebuild($identifiers, $module_name = 'configuration') {
if ($fields = configuration_get_default('field', $module_name)) {
field_info_cache_clear();
foreach ($fields as $identifier => $field) {
if (in_array($identifier, $identifiers) || !empty($identifiers) && $identifiers[0] == '#import_all') {
// Create or update field.
$field_config = $field['field_config'];
if ($existing_field = field_info_field($field_config['field_name'])) {
field_update_field($field_config);
}
else {
field_create_field($field_config);
}
// Create or update field instance.
$field_instance = $field['field_instance'];
$existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
if ($existing_instance) {
field_update_instance($field_instance);
}
else {
field_create_instance($field_instance);
}
variable_set('menu_rebuild_needed', TRUE);
}
}
}
}