Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
WikibaseClientDataTypesHookHandler
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 onWikibaseClientDataTypes
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare( strict_types = 1 );
4
5namespace EntitySchema\Wikibase\Hooks;
6
7use EntitySchema\Wikibase\DataValues\EntitySchemaValue;
8use ValueFormatters\ValueFormatter;
9
10/**
11 * @license GPL-2.0-or-later
12 */
13class WikibaseClientDataTypesHookHandler {
14
15    public function onWikibaseClientDataTypes( array &$dataTypeDefinitions ) {
16        $dataTypeDefinitions = array_merge(
17            $dataTypeDefinitions,
18            [
19                'PT:entity-schema' => [
20                    'value-type' => 'wikibase-entityid',
21                    'deserializer-builder' => EntitySchemaValue::class,
22                    'formatter-factory-callback' => static fn () => new class implements ValueFormatter {
23                        /** @inheritDoc */
24                        public function format( $value ) {
25                            return "Entity schema not supported yet ({$value->getSchemaId()})";
26                        }
27                    },
28                ],
29            ]
30        );
31    }
32
33}