MediaWiki fundraising/REL1_35
DonorLanguage.php
Go to the documentation of this file.
1<?php
2
3class DonorLanguage implements StagingHelper {
4 public function stage( GatewayType $adapter, $normalized, &$stagedData ) {
5 if ( !isset( $normalized['language'] ) ) {
6 return;
7 }
8 $language = $normalized['language'];
9 $adapterLanguages = $adapter->getAvailableLanguages();
10 if ( !in_array( $language, $adapterLanguages ) ) {
11 $fallbacks = WmfFramework::getLanguageFallbacks( $language );
12 foreach ( $fallbacks as $fallback ) {
13 if ( in_array( $fallback, $adapterLanguages ) ) {
14 $language = $fallback;
15 break;
16 }
17 }
18 }
19
20 if ( !in_array( $language, $adapterLanguages ) ) {
21 $language = 'en';
22 }
23
24 $stagedData['language'] = $language;
25 }
26}
$fallback
stage(GatewayType $adapter, $normalized, &$stagedData)
Transform a subset of normalized data into the "staged" data expected by a payment processor.
GatewayType Interface.
Used to mark any class which implements an staging method, for transforming data into the form expect...