jenkins-bot has submitted this change and it was merged. 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, 34 insertions(+), 26 deletions(-) Approvals: Ejegg: Looks good to me, approved jenkins-bot: Verified 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..79de798 100644 --- a/sites/all/modules/wmf_audit/wmf_audit.module +++ b/sites/all/modules/wmf_audit/wmf_audit.module @@ -28,6 +28,20 @@ } /** + * Dispatches to the correct processor. + * + * @param string $gateway name + * @param array $options Runtime parameters + */ +function wmf_audit_main( $gateway, $options ) { + $audit = module_hook_invoke( "{$gateway}_audit", 'create_processor', $options ); + if ( !$audit ) { + throw new Exception( "Gateway [$gateway] not found" ); + } + $audit->run(); +} + +/** * 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: merged Gerrit-Change-Id: I55531d642d848268031978ea01655494c23fa85d Gerrit-PatchSet: 5 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Awight <[email protected]> Gerrit-Reviewer: Ejegg <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
