Browse Source

Adjusted the code to be backwards compatible with previous implementation

Stephen Ficklin 4 years ago
parent
commit
e28a91ad04

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

@@ -636,6 +636,7 @@ function tripal_tripal_cron_notification() {
   foreach ($all_bundles as $bundle_name) {
     // Get the bundle object.
     $bundle = tripal_load_bundle_entity(['name' => $bundle_name->name]);
+    $term = tripal_load_term_entity(['term_id' => $bundle->term_id]);
     if (!$bundle) {
       tripal_report_error('tripal', TRIPAL_ERROR, "Unrecognized bundle name '%bundle'.",
         ['%bundle' => $bundle_name]);
@@ -647,7 +648,7 @@ function tripal_tripal_cron_notification() {
       $function = $module . '_bundle_fields_info';
       $entity_type = 'TripalEntity';
       $info = $function($entity_type, $bundle);
-      drupal_alter('bundle_fields_info', $info, $entity_type, $bundle);
+      drupal_alter('bundle_fields_info', $info, $bundle, $term);
       foreach ($info as $field_name => $details) {
 
         // If the field already exists then skip it.
@@ -674,7 +675,7 @@ function tripal_tripal_cron_notification() {
       $function = $module . '_bundle_instances_info';
       $entity_type = 'TripalEntity';
       $info = $function($entity_type, $bundle);
-      drupal_alter('bundle_instances_info', $info, $entity_type, $bundle);
+      drupal_alter('bundle_instances_info', $info, $bundle, $term);
       foreach ($info as $field_name => $details) {
 
         // If the field is already attached to this bundle then skip it.

+ 10 - 2
tripal/api/tripal.fields.api.inc

@@ -105,8 +105,12 @@ function hook_bundle_fields_info($entity_type, $bundle) {
  *
  * @param $info
  *  The fields info array for all fields.
+ * @param $bundle
+ *  The bundle content type object that the field belongs to.
+ * @param $term
+ *  The bundle type term.
  */
-function hook_bundle_fields_info_alter(&$info, $entity_type, $bundle) {
+function hook_bundle_fields_info_alter(&$info, $bundle, $term) {
 
 }
 
@@ -136,8 +140,12 @@ function hook_bundle_instances_info($entity_type, $bundle) {
  *
  * @param $info
  *  The field instance info array for all fields.
+ * @param $bundle
+ *  The bundle content type object that the field belongs to.
+ * @param $term
+ *  The bundle type term.
  */
-function hook_bundle_instances_info_alter(&$info, $entity_type, $bundle) {
+function hook_bundle_instances_info_alter(&$info, $bundle, $term) {
 
 }
 /**

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

@@ -17,6 +17,7 @@
 function tripal_admin_notification_import_field($field_name_note, $bundle_id, $module, $field_or_instance) {
   // Get the bundle object.
   $bundle = tripal_load_bundle_entity(['name' => $bundle_id]);
+  $term = tripal_load_term_entity(['term_id' => $bundle->term_id]);
   if (!$bundle) {
     tripal_report_error('tripal', TRIPAL_ERROR, "Unrecognized bundle name '%bundle'.",
       ['%bundle' => $bundle_id]);
@@ -28,7 +29,7 @@ function tripal_admin_notification_import_field($field_name_note, $bundle_id, $m
     $function = $module . '_bundle_fields_info';
     $entity_type = 'TripalEntity';
     $info = $function($entity_type, $bundle);
-    drupal_alter('bundle_fields_info', $info, $entity_type, $bundle);
+    drupal_alter('bundle_fields_info', $info, $bundle, $term);
     foreach ($info as $field_name => $details) {
       $field = field_info_field($field_name);
       if ($details['field_name'] == $field_name_note) {
@@ -48,7 +49,7 @@ function tripal_admin_notification_import_field($field_name_note, $bundle_id, $m
       $function = $module . '_bundle_instances_info';
       $entity_type = 'TripalEntity';
       $info = $function($entity_type, $bundle);
-      drupal_alter('_bundle_instances_info', $info, $entity_type, $bundle);
+      drupal_alter('_bundle_instances_info', $info, $bundle, $term);
       foreach ($info as $field_name => $details) {
         if ($details['field_name'] == $field_name_note) {
           // Create the field instance.