function( MediaWikiServices $services ) { // NOTE: Defining the LBFactory class via LBFactoryConf is supported for // backwards compatibility. The preferred way would be to register a // callback for DBLoadBalancerFactory that constructs the desired LBFactory // directly. $config = $services->getMainConfig()->get( 'LBFactoryConf' ); $class = LBFactory::getLBFactoryClass( $config ); if ( !isset( $config['readOnlyReason'] ) ) { // TODO: replace the global wfConfiguredReadOnlyReason() with a service. $config['readOnlyReason'] = wfConfiguredReadOnlyReason(); } return new $class( $config ); }, 'DBLoadBalancer' => function( MediaWikiServices $services ) { // just return the default LB from the DBLoadBalancerFactory service return $services->getDBLoadBalancerFactory()->getMainLB(); }, 'SiteStore' => function( MediaWikiServices $services ) { $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() ); // TODO: replace wfGetCache with a CacheFactory service. // TODO: replace wfIsHHVM with a capabilities service. $cache = wfGetCache( wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING ); return new CachingSiteStore( $rawSiteStore, $cache ); }, 'SiteLookup' => function( MediaWikiServices $services ) { // Use the default SiteStore as the SiteLookup implementation for now return $services->getSiteStore(); }, 'ConfigFactory' => function( MediaWikiServices $services ) { // Use the bootstrap config to initialize the ConfigFactory. $registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' ); $factory = new ConfigFactory(); foreach ( $registry as $name => $callback ) { $factory->register( $name, $callback ); } return $factory; }, 'MainConfig' => function( MediaWikiServices $services ) { // Use the 'main' config from the ConfigFactory service. return $services->getConfigFactory()->makeConfig( 'main' ); }, /////////////////////////////////////////////////////////////////////////// // NOTE: When adding a service here, don't forget to add a getter function // in the MediaWikiServices class. The convenience getter should just call // $this->getService( 'FooBarService' ). /////////////////////////////////////////////////////////////////////////// ];