function field_test_field_attach_rename_bundle
Implements hook_field_attach_rename_bundle().
File
-
modules/
field/ tests/ field_test.storage.inc, line 325
Code
function field_test_field_attach_rename_bundle($bundle_old, $bundle_new) {
$data = _field_test_storage_data();
// We need to account for deleted or inactive fields and instances.
$instances = field_read_instances(array(
'bundle' => $bundle_new,
), array(
'include_deleted' => TRUE,
'include_inactive' => TRUE,
));
foreach ($instances as $field_name => $instance) {
$field = field_info_field_by_id($instance['field_id']);
if ($field['storage']['type'] == 'field_test_storage') {
$field_data =& $data[$field['id']];
foreach (array(
'current',
'revisions',
) as $sub_table) {
foreach ($field_data[$sub_table] as &$row) {
if ($row->bundle == $bundle_old) {
$row->bundle = $bundle_new;
}
}
}
}
}
_field_test_storage_data($data);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.