Jelajahi Sumber

Fixed issues with dashboard notification creation of fields

Stephen Ficklin 4 tahun lalu
induk
melakukan
2f1fc47269

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

@@ -636,12 +636,13 @@ 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]);
       return FALSE;
     }
+    $term = tripal_load_term_entity(['term_id' => $bundle->term_id]);
+
     // Allow modules to add fields to the new bundle.
     $modules = module_implements('bundle_fields_info');
     foreach ($modules as $module) {

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

@@ -17,14 +17,16 @@
 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]);
     drupal_goto("admin/dashboard");
     return FALSE;
   }
+  $term = tripal_load_term_entity(['term_id' => $bundle->term_id]);
+
 
+  $instance = NULL;
   if ($field_or_instance == 'field') {
     $function = $module . '_bundle_fields_info';
     $entity_type = 'TripalEntity';
@@ -49,7 +51,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, $bundle, $term);
+      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.
@@ -73,7 +75,7 @@ function tripal_admin_notification_import_field($field_name_note, $bundle_id, $m
       ->execute();
   }
   else {
-    drupal_set_message(t("There was a problem creating: %field", ['%field' => $info[$field_name]['label']]));
+    drupal_set_message(t("There was a problem creating field."), 'error');
   }
 
   drupal_goto("admin/dashboard");