Stephen Ficklin 4 gadi atpakaļ
vecāks
revīzija
e29e4d53c3

+ 2 - 0
tripal/api/tripal.entities.api.inc

@@ -646,6 +646,7 @@ function tripal_tripal_cron_notification() {
     foreach ($modules as $module) {
       $function = $module . '_bundle_fields_info';
       $info = $function('TripalEntity', $bundle);
+      drupal_alter('bundle_fields_info', $info, 'TripalEntity', $bundle);
       foreach ($info as $field_name => $details) {
 
         // If the field already exists then skip it.
@@ -671,6 +672,7 @@ function tripal_tripal_cron_notification() {
     foreach ($modules as $module) {
       $function = $module . '_bundle_instances_info';
       $info = $function('TripalEntity', $bundle);
+      drupal_alter('bundle_instances_info', $info, 'TripalEntity', $bundle);
       foreach ($info as $field_name => $details) {
 
         // If the field is already attached to this bundle then skip it.

+ 32 - 0
tripal/api/tripal.fields.api.inc

@@ -94,6 +94,22 @@ function hook_bundle_fields_info($entity_type, $bundle) {
 
 }
 
+/**
+ * Allows a module to adjust a field's info settings.
+ *
+ * Modules should only adjust the info array for fields that
+ * they manage and not fields that were created by other modules. For example,
+ * if a field corresponds to a column in a custom table of Chado, then the
+ * tripal_chado module will automatically create a field for it. This function
+ * can be used to override the default settings created by Chado.
+ *
+ * @param $info
+ *  The fields info array for all fields.
+ */
+function hook_bundle_fields_info_alter(&$info, $entity_type, $bundle) {
+
+}
+
 /**
  * Allows a module to return the field instances of a bundle.
  *
@@ -108,6 +124,22 @@ function hook_bundle_instances_info($entity_type, $bundle) {
 
 }
 
+
+/**
+ * Allows a module to adjust field instances info settings.
+ *
+ * Modules should only adjust the info array for field instances that
+ * they manage and not fields that were created by other modules. For example,
+ * if a field corresponds to a column in a custom table of Chado, then the
+ * tripal_chado module will automatically create a field for it. This function
+ * can be used to override the default settings created by Chado.
+ *
+ * @param $info
+ *  The field instance info array for all fields.
+ */
+function hook_bundle_instances_info_alter(&$info, $entity_type, $bundle) {
+
+}
 /**
  * Indicate if a field has an empty value.
  *

+ 2 - 0
tripal/includes/tripal.admin_blocks.inc

@@ -27,6 +27,7 @@ function tripal_admin_notification_import_field($field_name_note, $bundle_id, $m
   if ($field_or_instance == 'field') {
     $function = $module . '_bundle_fields_info';
     $info = $function('TripalEntity', $bundle);
+    drupal_alter('bundle_fields_info', $info, 'TripalEntity', $bundle);
     foreach ($info as $field_name => $details) {
       $field = field_info_field($field_name);
       if ($details['field_name'] == $field_name_note) {
@@ -45,6 +46,7 @@ function tripal_admin_notification_import_field($field_name_note, $bundle_id, $m
     if ($field_or_instance == 'instance') {
       $function = $module . '_bundle_instances_info';
       $info = $function('TripalEntity', $bundle);
+      drupal_alter('_bundle_instances_info', $info, 'TripalEntity', $bundle);
       foreach ($info as $field_name => $details) {
         if ($details['field_name'] == $field_name_note) {
           // Create the field instance.