mediawiki-extensions-AbuseF.../includes/ServiceWiring.php
Daimona Eaytoy 1f8df50cb3 Add a service to retrieve the central DB
This is a thin wrapper around LBFactory and the global variable, that
can be injected in classes requiring it (no real class right now, but
that's going to change soon).

Also, remove some DWIM-style returns which made the code harder to
understand.

Change-Id: I1d28ad4a67f914103f3a17cda5f61b28070c7f1c
2020-10-31 12:32:46 +00:00

71 lines
2.6 KiB
PHP

<?php
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager as PermManager;
use MediaWiki\Extension\AbuseFilter\BlockAutopromoteStore;
use MediaWiki\Extension\AbuseFilter\CentralDBManager;
use MediaWiki\Extension\AbuseFilter\ChangeTagger;
use MediaWiki\Extension\AbuseFilter\ChangeTagsManager;
use MediaWiki\Extension\AbuseFilter\FilterProfiler;
use MediaWiki\Extension\AbuseFilter\FilterUser;
use MediaWiki\Extension\AbuseFilter\Hooks\AbuseFilterHookRunner;
use MediaWiki\Extension\AbuseFilter\KeywordsManager;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
return [
KeywordsManager::SERVICE_NAME => function ( MediaWikiServices $services ): KeywordsManager {
return new KeywordsManager(
new AbuseFilterHookRunner( $services->getHookContainer() )
);
},
FilterProfiler::SERVICE_NAME => function ( MediaWikiServices $services ): FilterProfiler {
return new FilterProfiler(
$services->getMainObjectStash(),
new ServiceOptions(
FilterProfiler::CONSTRUCTOR_OPTIONS,
$services->getMainConfig()
),
WikiMap::getCurrentWikiDbDomain()->getId(),
$services->getStatsdDataFactory(),
LoggerFactory::getInstance( 'AbuseFilter' )
);
},
PermManager::SERVICE_NAME => function ( MediaWikiServices $services ): PermManager {
return new PermManager( $services->getPermissionManager() );
},
ChangeTagger::SERVICE_NAME => function ( MediaWikiServices $services ) : ChangeTagger {
return new ChangeTagger(
$services->getService( ChangeTagsManager::SERVICE_NAME )
);
},
ChangeTagsManager::SERVICE_NAME => function ( MediaWikiServices $services ): ChangeTagsManager {
return new ChangeTagsManager(
$services->getDBLoadBalancer(),
$services->getMainWANObjectCache(),
$services->get( CentralDBManager::SERVICE_NAME )
);
},
CentralDBManager::SERVICE_NAME => function ( MediaWikiServices $services ): CentralDBManager {
return new CentralDBManager(
$services->getDBLoadBalancerFactory(),
$services->getMainConfig()->get( 'AbuseFilterCentralDB' )
);
},
BlockAutopromoteStore::SERVICE_NAME => function ( MediaWikiServices $services ): BlockAutopromoteStore {
return new BlockAutopromoteStore(
ObjectCache::getInstance( 'db-replicated' ),
LoggerFactory::getInstance( 'AbuseFilter' ),
$services->get( FilterUser::SERVICE_NAME )
);
},
FilterUser::SERVICE_NAME => function ( MediaWikiServices $services ): FilterUser {
return new FilterUser(
// TODO We need a proper MessageLocalizer, see T247127
RequestContext::getMain(),
$services->getUserGroupManager(),
LoggerFactory::getInstance( 'AbuseFilter' )
);
},
];