Awight has uploaded a new change for review.

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

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, 24 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/65/286765/1

diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 9189b7b..6deb60d 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -502,9 +502,32 @@
                                $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.
+        *
+        * TODO: Figure out why this isn't the default behavior in 
addResponseData.
+        * Once that's resolved, we might operate on member fields rather than 
be a pipe.
+        */
+       public function unstageKeys( $staged_data, $key_map = null ) {
+               if ( $key_map === null ) {
+                       $key_map = $this->config['var_map'];
+               }
+
+               $addme = array( );
+               foreach ( $key_map as $theirs => $ours ) {
+                       if ( isset( $staged_data[$theirs] ) ) {
+                               $addme[$ours] = $staged_data[$theirs];
+                       } else {
+                               $emptyVars[] = $theirs;
+                       }
+               }
+               return $addme;
+       }
+
        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: newchange
Gerrit-Change-Id: Idb87be3da1faff6b638f67e399493cf76fba55d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
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