Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_attach_rename_bundle.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_attach_rename_bundle.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_attach_rename_bundle.twig
new file mode 100644 (file)
index 0000000..5fea27d
--- /dev/null
@@ -0,0 +1,14 @@
+/**
+ * Implements hook_field_attach_rename_bundle().
+ */
+function {{ machine_name }}_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
+  // Update the extra weights variable with new information.
+  if ($bundle_old !== $bundle_new) {
+    $extra_weights = variable_get('field_extra_weights', array());
+    if (isset($info[$entity_type][$bundle_old])) {
+      $extra_weights[$entity_type][$bundle_new] = $extra_weights[$entity_type][$bundle_old];
+      unset($extra_weights[$entity_type][$bundle_old]);
+      variable_set('field_extra_weights', $extra_weights);
+    }
+  }
+}