Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/287171
Change subject: Implement IsoDate ...................................................................... Implement IsoDate Stages and unstages for any gateway that talks in ISO 8601 dates. Change-Id: I83f2ab6ea8dab6b528553140511a5a09460ba806 --- M DonationInterface.php A gateway_common/IsoDate.php M paypal_gateway/express_checkout/config/transformers.yaml 3 files changed, 23 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/71/287171/1 diff --git a/DonationInterface.php b/DonationInterface.php index 7fe1f58..fc22f45 100644 --- a/DonationInterface.php +++ b/DonationInterface.php @@ -59,6 +59,7 @@ $wgAutoloadClasses['GatewayAdapter'] = __DIR__ . '/gateway_common/gateway.adapter.php'; $wgAutoloadClasses['GatewayPage'] = __DIR__ . '/gateway_common/GatewayPage.php'; $wgAutoloadClasses['GatewayType'] = __DIR__ . '/gateway_common/GatewayType.php'; +$wgAutoloadClasses['IsoDate'] = __DIR__ . '/gateway_common/IsoDate.php'; $wgAutoloadClasses['DataValidator'] = __DIR__ . '/gateway_common/DataValidator.php'; $wgAutoloadClasses['LogPrefixProvider'] = __DIR__ . '/gateway_common/gateway.adapter.php'; $wgAutoloadClasses['MessageUtils'] = __DIR__ . '/gateway_common/MessageUtils.php'; diff --git a/gateway_common/IsoDate.php b/gateway_common/IsoDate.php new file mode 100644 index 0000000..3a374d9 --- /dev/null +++ b/gateway_common/IsoDate.php @@ -0,0 +1,21 @@ +<?php + +class IsoDate + implements + StagingHelper, + UnstagingHelper +{ + public function stage( GatewayType $adapter, $normalized, &$staged_data ) { + // Print timestamp as ISO 8601 string. + if ( isset( $normalized['date'] ) ) { + $staged_data['date'] = date( DateTime::ISO8601, $normalized['date'] ); + } + } + + public function unstage( GatewayType $adapter, $staged_data, &$unstaged_data ) { + // Parse ISO 8601 string to timestamp. + if ( isset( $staged_data['date'] ) ) { + $unstaged_data['date'] = strtotime( $staged_data['date'] ); + } + } +} diff --git a/paypal_gateway/express_checkout/config/transformers.yaml b/paypal_gateway/express_checkout/config/transformers.yaml index 72d814b..6013933 100644 --- a/paypal_gateway/express_checkout/config/transformers.yaml +++ b/paypal_gateway/express_checkout/config/transformers.yaml @@ -1 +1,2 @@ +- IsoDate - PaypalExpressReturnUrl -- To view, visit https://gerrit.wikimedia.org/r/287171 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I83f2ab6ea8dab6b528553140511a5a09460ba806 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits