'string', 'validator-factory-callback' => static function () { // load validator builders $factory = WikibaseRepo::getDefaultValidatorBuilders(); // initialize an array with string validators // returns an array of validators // that add basic string validation such as preventing empty strings $validators = $factory->buildStringValidators(); $validators[] = new MathValidator(); return $validators; }, 'parser-factory-callback' => static function ( ParserOptions $options ) { $normalizer = new WikibaseStringValueNormalizer( WikibaseRepo::getStringNormalizer() ); return new StringParser( $normalizer ); }, 'formatter-factory-callback' => static function ( $format, FormatterOptions $options ) { return new MathFormatter( $format ); }, 'rdf-builder-factory-callback' => static function ( $mode, RdfVocabulary $vocab, RdfWriter $writer, EntityMentionListener $tracker, DedupeBag $dedupe ) { return new MathMLRdfBuilder(); }, ]; } /** * Add Datatype "Math" to the Wikibase Client * @param array[] &$dataTypeDefinitions */ public static function onWikibaseClientDataTypes( array &$dataTypeDefinitions ) { global $wgMathEnableWikibaseDataType; if ( !$wgMathEnableWikibaseDataType ) { return; } $dataTypeDefinitions['PT:math'] = [ 'value-type' => 'string', 'formatter-factory-callback' => static function ( $format, FormatterOptions $options ) { return new MathFormatter( $format ); }, ]; } }