mediawiki-extensions-Cookie.../includes/ServiceWiring.php
Florian Schmidt 6634e8c829 Enable GeoLocation service being replaced by other providers
Making GeoLocation an interface makes it easier to replace the underlying implementation
from the current Http backed method.

Change-Id: I2beb97772fd74ab08b2214c08d82dbc1ebfcdcd2
2019-11-21 17:31:23 +01:00

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() );
},
];