1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Wikibase\QueryEngine\SQLStore; |
4
|
|
|
|
5
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\BooleanHandler; |
6
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\EntityIdHandler; |
7
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\GlobeCoordinateHandler; |
8
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\IriHandler; |
9
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\LatLongHandler; |
10
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\MonolingualTextHandler; |
11
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\NumberHandler; |
12
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\QuantityHandler; |
13
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\StringHandler; |
14
|
|
|
use Wikibase\QueryEngine\SQLStore\DVHandler\TimeHandler; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @licence GNU GPL v2+ |
18
|
|
|
* @author Jeroen De Dauw < [email protected] > |
19
|
|
|
*/ |
20
|
|
|
class DataValueHandlersBuilder { |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var DataValueHandlers |
24
|
|
|
*/ |
25
|
|
|
private $handlers; |
26
|
|
|
|
27
|
|
|
public function __construct() { |
28
|
|
|
$this->handlers = new DataValueHandlers(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @since 0.3 |
33
|
|
|
* @return self |
34
|
|
|
*/ |
35
|
|
|
public function withSimpleHandlers() { |
36
|
|
|
return $this->withSimpleMainSnakHandlers()->withSimpleQualifierHandlers(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @since 0.3 |
41
|
|
|
* @return self |
42
|
|
|
*/ |
43
|
|
|
public function withSimpleMainSnakHandlers() { |
44
|
|
|
$this->handlers->addMainSnakHandler( 'boolean', new BooleanHandler() ); |
45
|
|
|
$this->handlers->addMainSnakHandler( 'iri', new IriHandler() ); |
46
|
|
|
$this->handlers->addMainSnakHandler( 'geocoordinate', new LatLongHandler() ); |
47
|
|
|
$this->handlers->addMainSnakHandler( 'globecoordinate', new GlobeCoordinateHandler() ); |
48
|
|
|
$this->handlers->addMainSnakHandler( 'monolingualtext', new MonolingualTextHandler() ); |
49
|
|
|
$this->handlers->addMainSnakHandler( 'number', new NumberHandler() ); |
50
|
|
|
$this->handlers->addMainSnakHandler( 'quantity', new QuantityHandler() ); |
51
|
|
|
$this->handlers->addMainSnakHandler( 'string', new StringHandler() ); |
52
|
|
|
$this->handlers->addMainSnakHandler( 'time', new TimeHandler() ); |
53
|
|
|
$this->handlers->addMainSnakHandler( 'wikibase-entityid', new EntityIdHandler() ); |
54
|
|
|
|
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @since 0.3 |
60
|
|
|
* @return self |
61
|
|
|
*/ |
62
|
|
|
public function withSimpleQualifierHandlers() { |
63
|
|
|
$this->handlers->addQualifierHandler( 'boolean', new BooleanHandler() ); |
64
|
|
|
$this->handlers->addQualifierHandler( 'iri', new IriHandler() ); |
65
|
|
|
$this->handlers->addQualifierHandler( 'geocoordinate', new LatLongHandler() ); |
66
|
|
|
$this->handlers->addQualifierHandler( 'globecoordinate', new GlobeCoordinateHandler() ); |
67
|
|
|
$this->handlers->addQualifierHandler( 'monolingualtext', new MonolingualTextHandler() ); |
68
|
|
|
$this->handlers->addQualifierHandler( 'number', new NumberHandler() ); |
69
|
|
|
$this->handlers->addQualifierHandler( 'quantity', new QuantityHandler() ); |
70
|
|
|
$this->handlers->addQualifierHandler( 'string', new StringHandler() ); |
71
|
|
|
$this->handlers->addQualifierHandler( 'time', new TimeHandler() ); |
72
|
|
|
$this->handlers->addQualifierHandler( 'wikibase-entityid', new EntityIdHandler() ); |
73
|
|
|
|
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @since 0.3 |
79
|
|
|
* @return DataValueHandlers |
80
|
|
|
*/ |
81
|
|
|
public function getHandlers() { |
82
|
|
|
return $this->handlers; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|