Преглед на файлове

Merge branch '7.x-3.x' of github.com:tripal/tripal into 7.x-3.x

Stephen Ficklin преди 6 години
родител
ревизия
83ef87cdf6
променени са 2 файла, в които са добавени 56 реда и са изтрити 1 реда
  1. 46 1
      tripal/api/tripal.importer.api.inc
  2. 10 0
      tripal/includes/TripalImporter.inc

+ 46 - 1
tripal/api/tripal.importer.api.inc

@@ -18,7 +18,7 @@
  */
 
 /**
- * Implements hook_handle_uplaoded_file().
+ * Implements hook_handle_uploaded_file().
  *
  * This is a Tripal hook that allows the module to set the proper
  * parameters for a file uploaded via the Tripal HTML5 uploader.
@@ -37,6 +37,37 @@ function hook_handle_uploaded_file($file, $type) {
 
 }
 
+/**
+ * Implements hook_importer_finish().
+ *
+ * This hook is executed before a TripalImporter has started.  This allows 
+ * modules to implement specific actions prior to execution.
+ *
+ * @param $importer
+ *   The instance of the TripalImporter class that just completed its run.
+ * @param $job_id
+ *   The job_id
+ */
+function hook_importer_start($importer) {
+  
+}
+
+/**
+ * Implements hook_importer_finish().
+ * 
+ * This hook is executed once a TripalImporter has completed but it's run
+ * and post run activities.  This allows modules to implement specific actions
+ * once loaders are completed.
+ * 
+ * @param $importer
+ *   The instance of the TripalImporter class that just completed its run.
+ * @param $job_id
+ *   The job_id 
+ */
+function hook_importer_finish($importer) {
+  
+}
+
 /**
  * Retrieves a list of TripalImporter Importers.
  *
@@ -126,11 +157,25 @@ function tripal_run_importer($import_id, TripalJob $job = NULL) {
         "updates are rolled back and will not be found in the database\n\n";
 
   try {
+    // Call the hook_importer_start functions.
+    $modules = module_implements('importer_start');
+    foreach ($modules as $module) {
+      $function = $module . '_importer_start';
+      $function($loader);
+    }
+    
     // Run the loader
     tripal_run_importer_run($loader, $job);
 
     // Handle the post run.
     tripal_run_importer_post_run($loader, $job);
+    
+    // Call the hook_importer_finish functions.
+    $modules = module_implements('importer_finish');
+    foreach ($modules as $module) {
+      $function = $module . '_importer_finish';
+      $function($loader);
+    }
 
     // Check for tables with new cvterms
     print "Remapping Chado Controlled vocabularies to Tripal Terms...";

+ 10 - 0
tripal/includes/TripalImporter.inc

@@ -721,5 +721,15 @@ class TripalImporter {
    */
   public function postRun() {
   }
+  
+  /**
+   * Retrieves the list of arguments that were provided to the importer.
+   * 
+   * @return
+   *   The array of arguments as passed to create function.
+   */
+  public function getArguments() {
+    return $this->arguments;
+  }
 
 }