function field_attach_rename_bundle

Notifies 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()
comment_node_type_update in drupal/core/modules/comment/comment.module
Implements hook_node_type_update().
field_test_rename_bundle in drupal/core/modules/field/tests/modules/field_test/field_test.entity.inc
Renames a bundle for test_entity entities.
node_type_save in drupal/core/modules/node/node.module
Saves a node type to the database.
VocabularyStorageController::postSave in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyStorageController.php
Overrides Drupal\Core\Entity\DatabaseStorageController::postSave().

File

drupal/core/modules/field/field.attach.inc, line 1587
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();
  entity_info_cache_clear();

  // Update bundle settings.
  $settings = variable_get('field_bundle_settings_' . $entity_type . '__' . $bundle_old, array());
  variable_set('field_bundle_settings_' . $entity_type . '__' . $bundle_new, $settings);
  variable_del('field_bundle_settings_' . $entity_type . '__' . $bundle_old);

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