1 | <?php |
||
20 | class ApiEntityStore extends EntityStore { |
||
21 | |||
22 | /** |
||
23 | * @var DispatchingEntityLookup |
||
24 | */ |
||
25 | private $entityLookup; |
||
26 | |||
27 | /** |
||
28 | * @var DispatchingEntityIdForTermLookup |
||
29 | */ |
||
30 | private $entityIdsForTermLookup; |
||
31 | |||
32 | /** |
||
33 | * @var WikidataQueryApi|null |
||
34 | */ |
||
35 | private $wikidataQueryApi; |
||
36 | |||
37 | /** |
||
38 | * @param MediawikiApi $api |
||
39 | * @param WikidataQueryApi|null $wikidataQueryApi |
||
40 | * @param EntityStoreOptions|null $options |
||
41 | */ |
||
42 | 9 | public function __construct( |
|
43 | MediawikiApi $api, |
||
44 | WikidataQueryApi $wikidataQueryApi = null, |
||
45 | EntityStoreOptions $options = null |
||
46 | ) { |
||
47 | 9 | parent::__construct( $options ); |
|
48 | |||
49 | 9 | $this->entityLookup = $this->newEntityLookup( $api ); |
|
50 | 9 | $this->entityIdsForTermLookup = $this->newEntityForTermLookup( $api ); |
|
51 | 9 | $this->wikidataQueryApi = $wikidataQueryApi; |
|
52 | 9 | } |
|
53 | |||
54 | 9 | private function newEntityLookup( MediawikiApi $api ) { |
|
55 | 9 | $serializationFactory = new EntitySerializationFactory(); |
|
56 | 9 | return new DispatchingEntityLookup( |
|
57 | 9 | new ApiEntityLookup( $api, $serializationFactory->newEntityDeserializer(), $this->getOptions() ) |
|
58 | 9 | ); |
|
59 | } |
||
60 | |||
61 | 9 | private function newEntityForTermLookup( MediawikiApi $api ) { |
|
64 | |||
65 | /** |
||
66 | * @see EntityStore::getEntityLookup |
||
67 | */ |
||
68 | 1 | public function getEntityLookup() { |
|
71 | |||
72 | /** |
||
73 | * @see EntityStore::getEntityDocumentLookup |
||
74 | */ |
||
75 | 2 | public function getEntityDocumentLookup() { |
|
78 | |||
79 | /** |
||
80 | * @see EntityStore::getItemLookup |
||
81 | */ |
||
82 | 2 | public function getItemLookup() { |
|
85 | |||
86 | /** |
||
87 | * @see EntityStore::getPropertyLookup |
||
88 | */ |
||
89 | 1 | public function getPropertyLookup() { |
|
92 | |||
93 | /** |
||
94 | * @see EntityStore::getItemIdForTermLookup |
||
95 | */ |
||
96 | 2 | public function getItemIdForTermLookup() { |
|
99 | |||
100 | /** |
||
101 | * @see EntityStore::getPropertyIdForTermLookup |
||
102 | */ |
||
103 | 2 | public function getPropertyIdForTermLookup() { |
|
106 | |||
107 | /** |
||
108 | * @see EntityStore::getItemIdForQueryLookup |
||
109 | */ |
||
110 | 3 | public function getItemIdForQueryLookup() { |
|
120 | } |
||
121 |