daniel added a comment.

@Physikerwelt Yes, that's the correct hook. In the hook handle, you would do 
something like this:

  public static function onWikibaseClientDataTypes( array &$dataTypeDefinitions 
) {
      $dataTypeDefinitions['PT:math'] = array(
          'value-type' => 'string',
          'validator-factory-callback' => function() {
              $repo = WikibaseRepo::getDefaultInstance();
              return new MathValidator( ... );
          },
          'parser-factory-callback' => function( $format, FormatterOptions 
$options ) {
              $repo = WikibaseRepo::getDefaultInstance();
              $normalizer = new WikibaseStringValueNormalizer( 
$repo->getStringNormalizer() );
              return new StringParser( $normalizer );
          }
          'formatter-factory-callback' => function( $format, FormatterOptions 
$options ) {
              $repo = WikibaseRepo::getDefaultInstance();
              return new MathFormatter( ... );
          },
      );
  }

Note the "PT:" prefix, indicating that "math" is a property type, not a value 
type ("VT:"). Also note that the extension point for adding data types is 
pretty new, and still in flux. The PT and VT prefixes were added only this 
week. I'll try to keep it more stable now though.


TASK DETAIL
  https://phabricator.wikimedia.org/T67397

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Physikerwelt, daniel
Cc: Llyrian, WickieTheViking, Aklapper, MGChecker, Micru, Sannita, 
Ricordisamoa, Rits, Liuxinyu970226, NiharikaKohli, Tpt, Physikerwelt, 
Wikidata-bugs, Bene, Tobias1984, Lydia_Pintscher, daniel, aude, Mbch331



_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to