mediawiki-extensions-Math/ServiceWiring.php
Moritz Schubotz (physikerwelt) 73c41b4626
Provide static Factory Class for Math related services
Initially we provide one service. More services will come in
the future.

Change-Id: I98a0f5f181f729e123a063dabf3597b5effa55b8
2022-07-22 18:59:11 +02:00

60 lines
2 KiB
PHP

<?php
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Extension\Math\InputCheck\InputCheckFactory;
use MediaWiki\Extension\Math\Math;
use MediaWiki\Extension\Math\MathConfig;
use MediaWiki\Extension\Math\MathWikibaseConfig;
use MediaWiki\Extension\Math\MathWikibaseConnector;
use MediaWiki\Extension\Math\Render\RendererFactory;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use Wikibase\Client\WikibaseClient;
return [
'Math.CheckerFactory' => static function ( MediaWikiServices $services ): InputCheckFactory {
return new InputCheckFactory(
new ServiceOptions(
InputCheckFactory::CONSTRUCTOR_OPTIONS,
$services->getMainConfig()
),
$services->getMainWANObjectCache(),
$services->getHttpRequestFactory(),
LoggerFactory::getInstance( 'Math' )
);
},
'Math.Config' => static function ( MediaWikiServices $services ): MathConfig {
return new MathConfig(
new ServiceOptions( MathConfig::CONSTRUCTOR_OPTIONS, $services->getMainConfig() )
);
},
'Math.RendererFactory' => static function ( MediaWikiServices $services ): RendererFactory {
return new RendererFactory(
new ServiceOptions(
RendererFactory::CONSTRUCTOR_OPTIONS,
$services->getMainConfig()
),
Math::getMathConfig( $services ),
$services->getUserOptionsLookup(),
LoggerFactory::getInstance( 'Math' )
);
},
'Math.WikibaseConnector' => static function ( MediaWikiServices $services ): MathWikibaseConnector {
return new MathWikibaseConnector(
$services->get( 'Math.WikibaseConfig' ),
WikibaseClient::getRepoLinker( $services ),
$services->getLanguageFactory(),
LoggerFactory::getInstance( 'Math' )
);
},
'Math.WikibaseConfig' => static function ( MediaWikiServices $services ): MathWikibaseConfig {
return new MathWikibaseConfig(
WikibaseClient::getEntityIdParser( $services ),
WikibaseClient::getEntityRevisionLookup( $services ),
WikibaseClient::getFallbackLabelDescriptionLookupFactory( $services ),
WikibaseClient::getSite( $services ),
$services->getMainConfig()
);
},
];