mediawiki-extensions-Math/ServiceWiring.php
Moritz Schubotz (physikerwelt) 480d241f97
Make dependency to Wikibase client config optional
The MathEntitySelector gets its config from wbRepo which caused a hard
dependency on the Wikibase client.
If the Wikibase client config is not available a default value (wikidata)
is used to determine the URL of the foreign repo.
As the dropdown will never do write operations, we restrict the repo
access to anonymous read only.

Bug: T313143
Change-Id: Iba33dfd32a78f4ad7c2e99a1f56218458ab884b4
2022-07-25 09:51:47 +02:00

55 lines
1.9 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\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() ),
ExtensionRegistry::getInstance()
);
},
'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(
new ServiceOptions( MathWikibaseConnector::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
WikibaseClient::getRepoLinker( $services ),
$services->getLanguageFactory(),
WikibaseClient::getEntityRevisionLookup( $services ),
WikibaseClient::getFallbackLabelDescriptionLookupFactory( $services ),
WikibaseClient::getSite( $services ),
WikibaseClient::getEntityIdParser( $services ),
LoggerFactory::getInstance( 'Math' )
);
}
];