浏览代码

add updatedb to change widget and formatter for contact

dont lint whole file
bradfordcondon 6 年之前
父节点
当前提交
87fb34f474
共有 1 个文件被更改,包括 36 次插入0 次删除
  1. 36 0
      tripal_chado/tripal_chado.install

+ 36 - 0
tripal_chado/tripal_chado.install

@@ -1825,3 +1825,39 @@ function tripal_chado_update_7335() {
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
 }
+
+
+/**
+ * Use correct contact field when linked via linker table.
+ */
+function tripal_chado_update_7336() {
+
+  $bases = [
+    'feature',
+    'featuremap',
+    'library',
+    'nd_experiment',
+    'project',
+    'pubauthor',
+  ];
+
+  $bundles = field_info_instances('TripalEntity');
+
+  foreach ($bundles as $bundle_name => $fields) {
+
+    $bundle = tripal_load_bundle_entity(['name' => $bundle_name]);
+    $base = $bundle->data_table;
+
+    if (in_array($base, $bases)) {
+
+      $field_name = $base . '_contact';
+      $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
+
+      $instance_info['type'] = 'chado_linker__contact';
+      $instance_info['widget']['type'] = 'chado_linker__contact_widget';
+      $instance_info['formatter']['type'] = 'chado_linker__contact_widget';
+      field_update_instance($instance_info);
+
+    }
+  }
+}