Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| WikibaseClientHookHandler | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| onWikibaseClientDataTypes | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\Score; |
| 4 | |
| 5 | use MediaWiki\Config\Config; |
| 6 | use ValueFormatters\FormatterOptions; |
| 7 | use Wikibase\Client\Hooks\WikibaseClientDataTypesHook; |
| 8 | |
| 9 | class WikibaseClientHookHandler implements |
| 10 | WikibaseClientDataTypesHook |
| 11 | { |
| 12 | public function __construct( |
| 13 | private readonly Config $config, |
| 14 | ) { |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Add Datatype "Musical notation" to the Wikibase Client |
| 19 | */ |
| 20 | public function onWikibaseClientDataTypes( array &$dataTypeDefinitions ): void { |
| 21 | /** |
| 22 | * Enable the datatype in Quibble (CI) contexts so that we can test the integration |
| 23 | * of Score with Wikibase. |
| 24 | */ |
| 25 | if ( |
| 26 | !$this->config->get( 'MusicalNotationEnableWikibaseDataType' ) && |
| 27 | !defined( 'MW_QUIBBLE_CI' ) |
| 28 | ) { |
| 29 | return; |
| 30 | } |
| 31 | $dataTypeDefinitions['PT:musical-notation'] = [ |
| 32 | 'value-type' => 'string', |
| 33 | 'formatter-factory-callback' => function ( $format, FormatterOptions $options ) { |
| 34 | return new ScoreFormatter( $this->config, $format ); |
| 35 | }, |
| 36 | ]; |
| 37 | } |
| 38 | |
| 39 | } |