jenkins-bot has submitted this change and it was merged.

Change subject: Helper function to unstage the keys of an array
......................................................................


Helper function to unstage the keys of an array

I don't understand whether this magic already exists somewhere...

Change-Id: Idb87be3da1faff6b638f67e399493cf76fba55d5
---
M gateway_common/gateway.adapter.php
M worldpay_gateway/worldpay.adapter.php
2 files changed, 28 insertions(+), 0 deletions(-)

Approvals:
  Ejegg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index dee249d..399bccc 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -502,9 +502,36 @@
                                $newlyUnstagedData[$key] = 
$this->unstaged_data[$key];
                        }
                }
+               $this->logger->debug( "Adding response data: " . json_encode( 
$newlyUnstagedData ) );
                $this->dataObj->addData( $newlyUnstagedData );
        }
 
+       /**
+        * Change the keys on this data from processor API names to normalized 
names.
+        *
+        * @param array $processor_data Response data with raw API keys
+        * @return array data with normalized keys
+        *
+        * TODO: Figure out why this isn't the default behavior in 
addResponseData.
+        * Once that's resolved, we might operate on member fields rather than 
do
+        * this as a function.
+        */
+       public function unstageKeys( $processor_data, $key_map = null ) {
+               if ( $key_map === null ) {
+                       $key_map = $this->var_map;
+               }
+
+               $staged_data = array();
+               foreach ( $key_map as $their_key => $our_key ) {
+                       if ( isset( $processor_data[$their_key] ) ) {
+                               $staged_data[$our_key] = 
$processor_data[$their_key];
+                       } else {
+                               // TODO: do any callers care? $emptyVars[] = 
$their_key;
+                       }
+               }
+               return $staged_data;
+       }
+
        public function getData_Unstaged_Escaped( $val = '' ) {
                if ( $val === '' ) {
                        return $this->unstaged_data;
diff --git a/worldpay_gateway/worldpay.adapter.php 
b/worldpay_gateway/worldpay.adapter.php
index 6bdcfa3..cd53be1 100644
--- a/worldpay_gateway/worldpay.adapter.php
+++ b/worldpay_gateway/worldpay.adapter.php
@@ -702,6 +702,7 @@
         * @throws ResponseProcessingException if any required variables are 
missing
         */
        protected function addRequiredData( $data, $pull_vars ) {
+               // TODO: use unstageKeys
                $emptyVars = array( );
                $addme = array( );
                foreach ( $pull_vars as $theirs => $ours ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb87be3da1faff6b638f67e399493cf76fba55d5
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to