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

Change subject: Use GatewayType hints in a few places, add functions
......................................................................


Use GatewayType hints in a few places, add functions

Also moves the PHPDoc comments from the abstract adapter class into
the interface.

Change-Id: Ifc040dd7d069d087f38befb8d99cd3eb8d79c7e3
---
M gateway_common/DataValidator.php
M gateway_common/DonationLoggerFactory.php
M gateway_common/GatewayType.php
M gateway_common/PaymentMethod.php
M gateway_common/ResultPages.php
M gateway_common/gateway.adapter.php
6 files changed, 97 insertions(+), 72 deletions(-)

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



diff --git a/gateway_common/DataValidator.php b/gateway_common/DataValidator.php
index 956d439..a6e2457 100644
--- a/gateway_common/DataValidator.php
+++ b/gateway_common/DataValidator.php
@@ -180,7 +180,7 @@
         * validate
         * Run all the validation rules we have defined against a (hopefully
         * normalized) DonationInterface data set.
-        * @param GatewayAdapter $gateway
+        * @param GatewayType $gateway
         * @param array $data The DonationInterface data set, or a subset 
thereof.
         * @param array $check_not_empty An array of fields to do empty 
validation
         * on. If this is not populated, no fields will throw errors for being 
empty,
@@ -191,7 +191,7 @@
         * the main DonationInterface Form class to display. The array will be 
empty
         * if no errors were generated and everything passed OK.
         */
-       public static function validate( GatewayAdapter $gateway, $data, 
$check_not_empty = array()  ){
+       public static function validate( GatewayType $gateway, $data, 
$check_not_empty = array()  ){
                //return the array of errors that should be generated on 
validate.
                //just the same way you'd do it if you were a form passing the 
error array around. 
                
diff --git a/gateway_common/DonationLoggerFactory.php 
b/gateway_common/DonationLoggerFactory.php
index 63d324f..7e69ae3 100644
--- a/gateway_common/DonationLoggerFactory.php
+++ b/gateway_common/DonationLoggerFactory.php
@@ -16,13 +16,13 @@
        public static $overrideLogger = null;
 
        /**
-        * @param GatewayAdapter $adapter Get settings from this instance
+        * @param GatewayType $adapter Get settings from this instance
         * @param string $suffix Append this string to the adapter identifier
         * @param LogPrefixProvider $prefixer Optionally use this to override
         *        prefixing via the adapter.
         * @return \Psr\Log\LoggerInterface
         */
-       public static function getLogger( GatewayAdapter $adapter = null, 
$suffix = '', LogPrefixProvider $prefixer = null ) {
+       public static function getLogger( GatewayType $adapter = null, $suffix 
= '', LogPrefixProvider $prefixer = null ) {
                if ( self::$overrideLogger !== null ) {
                        return self::$overrideLogger;
                }
@@ -65,10 +65,10 @@
        /**
         * Retrieve a profiler instance which saves communication statistics
         * if the adapter's SaveCommStats global is set to true.
-        * @param GatewayAdapter $adapter
+        * @param GatewayType $adapter
         * @return DonationProfiler
         */
-       public static function getProfiler( GatewayAdapter $adapter ) {
+       public static function getProfiler( GatewayType $adapter ) {
                if ( $adapter::getGlobal( 'SaveCommStats' ) ) {
                        $commLogger = self::getLogger( $adapter, '_commstats' );
                } else {
diff --git a/gateway_common/GatewayType.php b/gateway_common/GatewayType.php
index c84ef79..93e33dd 100644
--- a/gateway_common/GatewayType.php
+++ b/gateway_common/GatewayType.php
@@ -8,6 +8,40 @@
        // all the particulars of the child classes. Aaaaall.
 
        /**
+        * Gets the name of the payment processor, e.g. Adyen
+        * @return string
+        */
+       public static function getGatewayName();
+
+       /**
+        * Get a tag to use to identify this adapter in logs, e.g. 
amazon_gateway
+        * @return string
+        */
+       public static function getLogIdentifier();
+
+       /**
+        * This function is important.
+        * All the globals in Donation Interface should be accessed in this 
manner
+        * if they are meant to have a default value, but can be overridden by 
any
+        * of the gateways. It will check to see if a gateway-specific global
+        * exists, and if one is not set, it will pull the default from the
+        * wgDonationInterface definitions. Through this function, it is no 
longer
+        * necessary to define gateway-specific globals in LocalSettings unless 
you
+        * wish to override the default value for all gateways.
+        * If the variable exists in {prefix}AccountInfo[currentAccountName],
+        * that value will override the default settings.
+        *
+        * @param string $varname The global value we're looking for. It will 
first
+        * look for a global named for the instantiated gateway's GLOBAL_PREFIX,
+        * plus the $varname value. If that doesn't come up with anything that 
has
+        * been set, it will use the default value for all of donation 
interface,
+        * stored in $wgDonationInterface . $varname.
+        * @return mixed The configured value for that gateway if it exists. If 
not,
+        * the configured value for Donation Interface if it exists or not.
+        */
+       public static function getGlobal( $varname );
+
+       /**
         * Process the API response obtained from the payment processor and set
         * properties of transaction_response
         * @param array|DomDocument $response Cleaned-up response returned from
@@ -158,9 +192,54 @@
 
        /**
         * Data format for responses coming back from the processor.
-        * Should be 'xml' // TODO: json
+        * Should be 'xml', 'json', or 'delimited'
         *
         * @return string
         */
        function getResponseType();
+
+       /**
+        * This is the ONLY getData type function anything should be using
+        * outside the adapter.
+        * Short explanation of the data population up to now:
+        *      *) When the gateway adapter is constructed, it constructs a 
DonationData
+        *              object.
+        *      *) On construction, the DonationData object pulls donation data 
from an
+        *              appropriate source, and normalizes the entire data set 
for storage.
+        *      *) The gateway adapter pulls normalized, html escaped data out 
of the
+        *              DonationData object, as the base of its own data set.
+        * @param string $val The specific key you're looking for (if any)
+        * @return mixed An array of all the raw, unstaged (but normalized and
+        * sanitized) data sent to the adapter, or if $val was set, either the
+        * specific value held for $val, or null if none exists.
+        */
+       public function getData_Unstaged_Escaped( $val = '' );
+
+       /**
+        * Retrieve the data we will need in order to retry a payment.
+        * This is useful in the event that we have just killed a session before
+        * the next retry.
+        * @return array Data required for a payment retry.
+        */
+       public function getRetryData();
+
+       /**
+        * Get metadata for the specified payment method as set in
+        * @see definePaymentMethods
+        *
+        * @param string|null $payment_method Defaults to the current method
+        * @return array
+        * @throws OutOfBoundsException
+        */
+       public function getPaymentMethodMeta( $payment_method = null );
+
+       /**
+        * Get metadata for the specified payment submethod
+        *
+        * @param string|null $payment_submethod Defaults to the current 
submethod
+        * @return array
+        * @throws OutOfBoundsException
+        */
+       public function getPaymentSubmethodMeta( $payment_submethod = null );
+
 }
diff --git a/gateway_common/PaymentMethod.php b/gateway_common/PaymentMethod.php
index adcf985..feaf44d 100644
--- a/gateway_common/PaymentMethod.php
+++ b/gateway_common/PaymentMethod.php
@@ -20,7 +20,7 @@
  */
 class PaymentMethod {
        /**
-        * @var GatewayAdapter $gateway
+        * @var GatewayType $gateway
         */
        protected $gateway;
 
@@ -36,7 +36,7 @@
        /**
         * Build a new PaymentMethod object from an name pair
         *
-        * @param GatewayAdapter $gateway
+        * @param GatewayType $gateway
         * @param string $method_name
         * @param string $submethod_name
         * @param bool $is_recurring
@@ -44,7 +44,7 @@
         * @return PaymentMethod
         */
        public static function newFromCompoundName(
-               GatewayAdapter $gateway, $method_name, $submethod_name, 
$is_recurring
+               GatewayType $gateway, $method_name, $submethod_name, 
$is_recurring
        ) {
                $method = new PaymentMethod();
                $method->gateway = $gateway;
diff --git a/gateway_common/ResultPages.php b/gateway_common/ResultPages.php
index 3800c54..6653a3f 100644
--- a/gateway_common/ResultPages.php
+++ b/gateway_common/ResultPages.php
@@ -4,11 +4,11 @@
        /**
         * Get the URL for a page to show donors after a successful donation,
         * with the country code appended as a query string variable
-        * @param GatewayAdapter $adapter
+        * @param GatewayType $adapter
         * @param array $extraParams any extra parameters to add to the URL
         * @return string
         */
-       public static function getThankYouPage( GatewayAdapter $adapter, 
$extraParams = array() ) {
+       public static function getThankYouPage( GatewayType $adapter, 
$extraParams = array() ) {
                $page = $adapter::getGlobal( "ThankYouPage" );
                if ( $page ) {
                        $page = self::appendLanguageAndMakeURL( $page, $adapter 
);
@@ -19,10 +19,10 @@
 
        /**
         * Get the URL for a page to show donors after a failed donation
-        * @param GatewayAdapter $adapter
+        * @param GatewayType $adapter
         * @return string
         */
-       public static function getFailPage( GatewayAdapter $adapter ) {
+       public static function getFailPage( GatewayType $adapter ) {
                // Prefer RapidFail.
                if ( $adapter::getGlobal( 'RapidFail' ) ) {
                        $data = $adapter->getData_Unstaged_Escaped();
@@ -53,10 +53,10 @@
 
        /**
         * Get the URL for a page to show donors who cancel their attempt
-        * @param GatewayAdapter $adapter
+        * @param GatewayType $adapter
         * @return string
         */
-       public static function getCancelPage( GatewayAdapter $adapter ) {
+       public static function getCancelPage( GatewayType $adapter ) {
                $cancelPage = $adapter->getGlobal( 'CancelPage' );
                if ( empty( $cancelPage ) ) {
                        return '';
@@ -70,10 +70,10 @@
         * appended onto the end.
         * @param string $url Either a wiki page title, or a URL to an external 
wiki
         * page title.
-        * @param GatewayAdapter $adapter
+        * @param GatewayType $adapter
         * @return string A URL
         */
-       protected static function appendLanguageAndMakeURL( $url, 
GatewayAdapter $adapter ) {
+       protected static function appendLanguageAndMakeURL( $url, GatewayType 
$adapter ) {
                $language = $adapter->getData_Unstaged_Escaped( 'language' );
                // make sure we don't already have the language in there...
                $dirs = explode('/', $url);
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 7619dee..47bd36b 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -417,21 +417,6 @@
                $this->dataObj->addData( $newlyUnstagedData );
        }
 
-       /**
-        * This is the ONLY getData type function anything should be using
-        * outside the adapter.
-        * Short explanation of the data population up to now:
-        *      *) When the gateway adapter is constructed, it constructs a 
DonationData
-        *              object.
-        *      *) On construction, the DonationData object pulls donation data 
from an
-        *              appropriate source, and normalizes the entire data set 
for storage.
-        *      *) The gateway adapter pulls normalized, html escaped data out 
of the
-        *              DonationData object, as the base of its own data set.
-        * @param string $val The specific key you're looking for (if any)
-        * @return mixed An array of all the raw, unstaged (but normalized and
-        * sanitized) data sent to the adapter, or if $val was set, either the
-        * specific value held for $val, or null if none exists.
-        */
        public function getData_Unstaged_Escaped( $val = '' ) {
                if ( $val === '' ) {
                        return $this->unstaged_data;
@@ -444,26 +429,6 @@
                }
        }
 
-       /**
-        * This function is important.
-        * All the globals in Donation Interface should be accessed in this 
manner
-        * if they are meant to have a default value, but can be overridden by 
any
-        * of the gateways. It will check to see if a gateway-specific global
-        * exists, and if one is not set, it will pull the default from the
-        * wgDonationInterface definitions. Through this function, it is no 
longer
-        * necessary to define gateway-specific globals in LocalSettings unless 
you
-        * wish to override the default value for all gateways.
-        * If the variable exists in {prefix}AccountInfo[currentAccountName],
-        * that value will override the default settings.
-        *
-        * @param string $varname The global value we're looking for. It will 
first
-        * look for a global named for the instantiated gateway's GLOBAL_PREFIX,
-        * plus the $varname value. If that doesn't come up with anything that 
has
-        * been set, it will use the default value for all of donation 
interface,
-        * stored in $wgDonationInterface . $varname.
-        * @return mixed The configured value for that gateway if it exists. If 
not,
-        * the configured value for Donation Interface if it exists or not.
-        */
        static function getGlobal( $varname ) {
                // adding another layer of depth here, in case you're working 
with two gateways in the same request.
                // That does, in fact, ruin everything. :/
@@ -3257,12 +3222,6 @@
                return $match;
        }
 
-       /**
-        * Retrieve the data we will need in order to retry a payment.
-        * This is useful in the event that we have just killed a session before
-        * the next retry.
-        * @return array Data required for a payment retry.
-        */
        public function getRetryData() {
                $params = array ( );
                foreach ( $this->dataObj->getRetryFields() as $field ) {
@@ -3675,13 +3634,6 @@
                $this->order_id_meta[$key] = $value;
        }
 
-       /**
-        * Get payment method meta
-        *
-        * @param string|null $payment_method Defaults to the current payment 
method, if null.
-        *
-        * @throws OutOfBoundsException
-        */
        public function getPaymentMethodMeta( $payment_method = null ) {
                if ( $payment_method === null ) {
                        $payment_method = $this->getPaymentMethod();
@@ -3697,12 +3649,6 @@
                }
        }
 
-       /**
-        * Get payment submethod meta
-        *
-        * @param    string|null    $payment_submethod    Payment submethods 
are mapped to paymentproductid
-        * @throws OutOfBoundsException
-        */
        public function getPaymentSubmethodMeta( $payment_submethod = null ) {
                if ( is_null( $payment_submethod ) ) {
                        $payment_submethod = $this->getPaymentSubmethod();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc040dd7d069d087f38befb8d99cd3eb8d79c7e3
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[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