mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
synced 2024-12-18 00:30:43 +00:00
6634e8c829
Making GeoLocation an interface makes it easier to replace the underlying implementation from the current Http backed method. Change-Id: I2beb97772fd74ab08b2214c08d82dbc1ebfcdcd2
28 lines
876 B
PHP
28 lines
876 B
PHP
<?php
|
|
|
|
use CookieWarning\Decisions;
|
|
use CookieWarning\HttpGeoLocation;
|
|
use CookieWarning\NoopGeoLocation;
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
return [
|
|
'CookieWarning.Config' => function ( MediaWikiServices $services ) {
|
|
return $services->getService( 'ConfigFactory' )
|
|
->makeConfig( 'cookiewarning' );
|
|
},
|
|
'GeoLocation' => function ( MediaWikiServices $services ) {
|
|
$geoIPServiceURL = $services
|
|
->getService( 'CookieWarning.Config' )
|
|
->get( 'CookieWarningGeoIPServiceURL' );
|
|
|
|
if ( !is_string( $geoIPServiceURL ) || !$geoIPServiceURL ) {
|
|
return new NoopGeoLocation();
|
|
}
|
|
return new HttpGeoLocation( $geoIPServiceURL );
|
|
},
|
|
'CookieWarning.Decisions' => function ( MediaWikiServices $services ) {
|
|
return new Decisions( $services->getService( 'CookieWarning.Config' ),
|
|
$services->getService( 'GeoLocation' ), $services->getMainWANObjectCache() );
|
|
},
|
|
];
|