-
Notifications
You must be signed in to change notification settings - Fork 5
/
WikibaseLexeme.entitytypes.php
179 lines (175 loc) · 6.28 KB
/
WikibaseLexeme.entitytypes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/**
* Definition of the lexeme entity type.
* The array returned by the code below is supposed to be merged into the Repo entity types.
*
* @note: Keep in sync with Wikibase
*
* @note: This is bootstrap code, it is executed for EVERY request. Avoid instantiating
* objects or loading classes here!
*
* @license GPL-2.0-or-later
* @author Amir Sarabadani <[email protected]>
*/
use Wikibase\DataAccess\NullPrefetchingTermLookup;
use Wikibase\DataModel\Deserializers\DeserializerFactory;
use Wikibase\DataModel\Serializers\SerializerFactory;
use Wikibase\Lexeme\DataAccess\Store\FormRevisionLookup;
use Wikibase\Lexeme\DataAccess\Store\FormStore;
use Wikibase\Lexeme\DataAccess\Store\FormTitleStoreLookup;
use Wikibase\Lexeme\DataAccess\Store\SenseRevisionLookup;
use Wikibase\Lexeme\DataAccess\Store\SenseStore;
use Wikibase\Lexeme\DataAccess\Store\SenseTitleStoreLookup;
use Wikibase\Lexeme\Domain\Diff\FormDiffer;
use Wikibase\Lexeme\Domain\Diff\FormPatcher;
use Wikibase\Lexeme\Domain\Diff\LexemeDiffer;
use Wikibase\Lexeme\Domain\Diff\LexemePatcher;
use Wikibase\Lexeme\Domain\Diff\SenseDiffer;
use Wikibase\Lexeme\Domain\Diff\SensePatcher;
use Wikibase\Lexeme\Domain\Model\FormId;
use Wikibase\Lexeme\Domain\Model\LexemeId;
use Wikibase\Lexeme\Domain\Model\SenseId;
use Wikibase\Lexeme\Serialization\ExternalLexemeSerializer;
use Wikibase\Lexeme\Serialization\FormSerializer;
use Wikibase\Lexeme\Serialization\LexemeDeserializer;
use Wikibase\Lexeme\Serialization\SenseSerializer;
use Wikibase\Lexeme\Serialization\StorageLexemeSerializer;
use Wikibase\Lib\EntityTypeDefinitions as Def;
use Wikibase\Lib\Store\EntityRevisionLookup;
use Wikibase\Lib\Store\EntityStore;
use Wikibase\Lib\Store\TitleLookupBasedEntityArticleIdLookup;
use Wikibase\Repo\Store\EntityTitleStoreLookup;
use Wikibase\Repo\WikibaseRepo;
return [
'lexeme' => [
Def::ARTICLE_ID_LOOKUP_CALLBACK => static function () {
return new TitleLookupBasedEntityArticleIdLookup(
WikibaseRepo::getEntityTitleLookup()
);
},
Def::SERIALIZER_FACTORY_CALLBACK => static function ( SerializerFactory $serializerFactory ) {
return new ExternalLexemeSerializer(
new StorageLexemeSerializer(
$serializerFactory->newTermListSerializer(),
$serializerFactory->newStatementListSerializer()
)
);
},
Def::DESERIALIZER_FACTORY_CALLBACK => static function ( DeserializerFactory $deserializerFactory ) {
return new LexemeDeserializer(
$deserializerFactory->newEntityIdDeserializer(),
$deserializerFactory->newStatementListDeserializer()
);
},
Def::ENTITY_ID_PATTERN => LexemeId::PATTERN,
Def::ENTITY_ID_BUILDER => static function ( $serialization ) {
return new LexemeId( $serialization );
},
Def::ENTITY_ID_COMPOSER_CALLBACK => static function ( $uniquePart ) {
return new LexemeId( 'L' . $uniquePart );
},
Def::ENTITY_DIFFER_STRATEGY_BUILDER => static function () {
return new LexemeDiffer();
},
Def::ENTITY_PATCHER_STRATEGY_BUILDER => static function () {
return new LexemePatcher();
},
// Identifier of a resource loader module that, when `require`d, returns a function
// returning a deserializer
Def::JS_DESERIALIZER_FACTORY_FUNCTION => 'wikibase.lexeme.getDeserializer',
Def::SUB_ENTITY_TYPES => [
'form',
'sense',
],
Def::LUA_ENTITY_MODULE => 'mw.wikibase.lexeme.entity.lexeme',
Def::PREFETCHING_TERM_LOOKUP_CALLBACK => static function () {
return new NullPrefetchingTermLookup();
},
],
'form' => [
Def::ARTICLE_ID_LOOKUP_CALLBACK => static function () {
return new TitleLookupBasedEntityArticleIdLookup(
WikibaseRepo::getEntityTitleLookup()
);
},
Def::ENTITY_STORE_FACTORY_CALLBACK => static function (
EntityStore $defaultStore,
EntityRevisionLookup $lookup
) {
return new FormStore( $defaultStore, $lookup );
},
Def::ENTITY_REVISION_LOOKUP_FACTORY_CALLBACK => static function (
EntityRevisionLookup $defaultLookup
) {
return new FormRevisionLookup( $defaultLookup );
},
Def::ENTITY_TITLE_STORE_LOOKUP_FACTORY_CALLBACK => static function (
EntityTitleStoreLookup $defaultLookup
) {
return new FormTitleStoreLookup( $defaultLookup );
},
Def::ENTITY_ID_PATTERN => FormId::PATTERN,
Def::ENTITY_ID_BUILDER => static function ( $serialization ) {
return new FormId( $serialization );
},
Def::ENTITY_DIFFER_STRATEGY_BUILDER => static function () {
return new FormDiffer();
},
Def::ENTITY_PATCHER_STRATEGY_BUILDER => static function () {
return new FormPatcher();
},
Def::SERIALIZER_FACTORY_CALLBACK => static function ( SerializerFactory $serializerFactory ) {
return new FormSerializer(
$serializerFactory->newTermListSerializer(),
$serializerFactory->newStatementListSerializer()
);
},
Def::PREFETCHING_TERM_LOOKUP_CALLBACK => static function () {
return new NullPrefetchingTermLookup();
},
DEF::LUA_ENTITY_MODULE => 'mw.wikibase.lexeme.entity.form',
],
'sense' => [
Def::ARTICLE_ID_LOOKUP_CALLBACK => static function () {
return new TitleLookupBasedEntityArticleIdLookup(
WikibaseRepo::getEntityTitleLookup()
);
},
Def::ENTITY_STORE_FACTORY_CALLBACK => static function (
EntityStore $defaultStore,
EntityRevisionLookup $lookup
) {
return new SenseStore( $defaultStore, $lookup );
},
Def::ENTITY_REVISION_LOOKUP_FACTORY_CALLBACK => static function (
EntityRevisionLookup $defaultLookup
) {
return new SenseRevisionLookup( $defaultLookup );
},
Def::ENTITY_TITLE_STORE_LOOKUP_FACTORY_CALLBACK => static function (
EntityTitleStoreLookup $defaultLookup
) {
return new SenseTitleStoreLookup( $defaultLookup );
},
Def::ENTITY_ID_PATTERN => SenseId::PATTERN,
Def::ENTITY_ID_BUILDER => static function ( $serialization ) {
return new SenseId( $serialization );
},
Def::ENTITY_DIFFER_STRATEGY_BUILDER => static function () {
return new SenseDiffer();
},
Def::ENTITY_PATCHER_STRATEGY_BUILDER => static function () {
return new SensePatcher();
},
Def::SERIALIZER_FACTORY_CALLBACK => static function ( SerializerFactory $serializerFactory ) {
return new SenseSerializer(
$serializerFactory->newTermListSerializer(),
$serializerFactory->newStatementListSerializer()
);
},
Def::PREFETCHING_TERM_LOOKUP_CALLBACK => static function () {
return new NullPrefetchingTermLookup();
},
DEF::LUA_ENTITY_MODULE => 'mw.wikibase.lexeme.entity.sense',
],
];