Skip navigation
Help

field_attach_rename_bundle

7 field.attach.inc field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)

Notify field.module that a bundle was renamed.

Parameters

$entity_type: The entity type to which the bundle is bound.

$bundle_old: The previous name of the bundle.

$bundle_new: The new name of the bundle.

Related topics

4 calls to field_attach_rename_bundle()

File

drupal/modules/field/field.attach.inc, line 1301
Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'.

Code

function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
  db_update('field_config_instance')
    ->fields(array('bundle' => $bundle_new))
    ->condition('entity_type', $entity_type)
    ->condition('bundle', $bundle_old)
    ->execute();

  // Clear the cache.
  field_cache_clear();

  // Update bundle settings.
  $settings = variable_get('field_bundle_settings', array());
  if (isset($settings[$entity_type][$bundle_old])) {
    $settings[$entity_type][$bundle_new] = $settings[$entity_type][$bundle_old];
    unset($settings[$entity_type][$bundle_old]);
    variable_set('field_bundle_settings', $settings);
  }

  // Let other modules act on renaming the bundle.
  module_invoke_all('field_attach_rename_bundle', $entity_type, $bundle_old, $bundle_new);
}