function node_reference_node_type_update in References 7.2
Implements hook_node_type_update().
Reflect type name changes to the 'referenceable types' settings: when the name of a type changes, the change needs to be reflected in the "referenceable types" setting for any node_reference field referencing it.
File
- node_reference/
node_reference.module, line 1014 - Defines a field type for referencing one node from another.
Code
function node_reference_node_type_update($info) {
if (!empty($info->old_type) && $info->old_type != $info->type) {
$fields = field_info_fields();
foreach ($fields as $field) {
if ($field['type'] == 'node_reference' && isset($field['settings']['referenceable_types'][$info->old_type])) {
$field['settings']['referenceable_types'][$info->type] = empty($field['settings']['referenceable_types'][$info->old_type]) ? 0 : $info->type;
unset($field['settings']['referenceable_types'][$info->old_type]);
field_update_field($field);
}
}
}
}