Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/220940

Change subject: Move the Drush command hook to the base module
......................................................................

Move the Drush command hook to the base module

Change-Id: I55531d642d848268031978ea01655494c23fa85d
---
R sites/all/modules/wmf_audit/wmf_audit.drush.inc
M sites/all/modules/wmf_audit/wmf_audit.module
M sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
3 files changed, 31 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/40/220940/1

diff --git a/sites/all/modules/wmf_audit/worldpay/worldpay_audit.drush.inc 
b/sites/all/modules/wmf_audit/wmf_audit.drush.inc
similarity index 69%
rename from sites/all/modules/wmf_audit/worldpay/worldpay_audit.drush.inc
rename to sites/all/modules/wmf_audit/wmf_audit.drush.inc
index 08e9097..86a2bb4 100644
--- a/sites/all/modules/wmf_audit/worldpay/worldpay_audit.drush.inc
+++ b/sites/all/modules/wmf_audit/wmf_audit.drush.inc
@@ -1,22 +1,26 @@
 <?php
 /**
  * @file wmf_audit.drush.inc
- * Parses reconciliation files from worldpay, and adds any missing data to 
civi.
+ * Parses reconciliation files and adds any missing data to civi.
  * @author Katie Horn <[email protected]>
  */
 
 /**
  * Implementation of hook_drush_command()
  */
-function worldpay_audit_drush_command() {
+function wmf_audit_drush_command() {
   $items = array();
 
-  $items['worldpay-audit'] = array(
+  $items['parse-audit'] = array(
     'description' =>
-      'Worldpay Audit tool: Parses worldpay reconciliation files and inserts 
any missing transactions into the message queues.',
+      'Worldpay Audit tool: Parses reconciliation files and inserts any 
missing transactions into the message queues.',
     'examples' => array(
-      'drush worldpay-audit' => '# Run the audit and rebuild job',
+      'drush parse-audit worldpay' => '# Run the audit and rebuild job',
     ),
+    'arguments' => array(
+      'gateway' => 'Gateway name to process',
+    ),
+    'required-arguments' => true,
     'options' => array(
       'run_all' => 'Batch search for all missing transactions across all 
available recon files, instead of just the top three',
       'test' => 'Test the audit and rebuild job, but do not generate stomp 
messages. No data will be changed.',
@@ -26,7 +30,6 @@
       'verbose' => 'Verbose output',
       'recon_complete_count' => 'Number past which we should consider a recon 
file to be "complete", and move it out of the working dir.',
     ),
-    'aliases' => array('wp_audit'),
   );
 
   return $items;
@@ -35,17 +38,17 @@
 /**
  * Implementation of hook_drush_help()
  */
-function worldpay_audit_drush_help($section) {
+function wmf_audit_drush_help($section) {
   switch ($section) {
-    case 'worldpay-audit':
-      return dt("Worldpay Audit tool: Parses worldpay reconciliation files and 
inserts any missing transactions into the message queues.");
+    case 'parse-audit':
+      return dt("Audit parsing tool: Parses reconciliation files and inserts 
any missing transactions into the message queues.");
   }
 }
 
 /**
  * Fires the 'wmf_audit_main' method with the appropriate parameters
  */
-function drush_worldpay_audit() {
+function drush_wmf_audit() {
 
   $simple_opts = array(
     'test' => 'Running in test mode: No stomp messages will be sent',
@@ -59,7 +62,7 @@
   $args = array();
 
   //handle our defaults first...
-  $args['test'] = variable_get('worldpay_audit_test_mode', WP_AUDIT_TEST_MODE);
+  $args['test'] = variable_get('wmf_audit_test_mode');
   //now override with the command line settings
   foreach ($simple_opts as $key => $message) {
     if (drush_get_option($key)) {
@@ -80,18 +83,5 @@
     $args['recon_complete_count'] = drush_get_option('recon_complete_count');
   }
 
-  module_invoke('wmf_audit', 'main', 'worldpay', $args);
-
-  $errors = drush_get_error_log();
-  if (!empty($errors)) {
-    echo "\n***ERRORS***";
-    foreach ($errors as $error => $msgarray) {
-      echo "\n$error: ";
-      foreach ($msgarray as $count => $message) {
-        echo "\n    $message";
-      }
-    }
-    echo "\n\n";
-    exit(drush_get_error());
-  }
+  wmf_audit_main( $gateway, $args );
 }
diff --git a/sites/all/modules/wmf_audit/wmf_audit.module 
b/sites/all/modules/wmf_audit/wmf_audit.module
index f40704c..3e23021 100644
--- a/sites/all/modules/wmf_audit/wmf_audit.module
+++ b/sites/all/modules/wmf_audit/wmf_audit.module
@@ -28,6 +28,17 @@
 }
 
 /**
+ * Dispatches to the correct processor.
+ *
+ * @param string $gateway name
+ * @param array $options Runtime parameters
+ */
+function wmf_audit_main( $gateway, $options ) {
+    $function_name = "{$gateway}_audit_create_processor";
+    $function_name( $options );
+}
+
+/**
  * Implements hook_permission.
  *
  * Exported permissions are:
diff --git a/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module 
b/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
index b83e6ef..3464329 100644
--- a/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
+++ b/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
@@ -14,7 +14,7 @@
   $items = array();
 
   $items['admin/config/wmf_audit/worldpay_audit'] = array(
-    'title' => 'WorldPay Audit',
+    'title' => 'Worldpay Audit',
     'description' => t('Configure WMF audit settings.'),
     'access arguments' => array('administer wmf_audit'),
     'page callback' => 'drupal_get_form',
@@ -60,3 +60,7 @@
   );
   return system_settings_form( $form );
 }
+
+function worldpay_audit_create_processor( $options ) {
+    return new WorldpayAuditProcessor( $options );
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/220940
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55531d642d848268031978ea01655494c23fa85d
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to