|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Wikibase\EntityStore\Config; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
6
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @licence GPLv2+ |
|
10
|
|
|
* @author Thomas Pellissier Tanon |
|
11
|
|
|
*/ |
|
12
|
|
|
class EntityStoreConfiguration implements ConfigurationInterface { |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @see ConfigurationInterface::getConfigTreeBuilder |
|
16
|
|
|
*/ |
|
17
|
19 |
|
public function getConfigTreeBuilder() { |
|
18
|
19 |
|
$treeBuilder = new TreeBuilder(); |
|
19
|
|
|
|
|
20
|
19 |
|
$rootNode = $treeBuilder->root( 'entitystore' ); |
|
21
|
|
|
$rootNode |
|
22
|
19 |
|
->children() |
|
23
|
19 |
|
->enumNode( 'backend' ) |
|
24
|
19 |
|
->values( [ 'api', 'mongodb' ] ) |
|
25
|
19 |
|
->info( 'The backend to use' ) |
|
26
|
19 |
|
->isRequired() |
|
27
|
19 |
|
->end() |
|
28
|
19 |
|
->arrayNode( 'api' ) |
|
29
|
19 |
|
->info( 'API backend configuration' ) |
|
30
|
19 |
|
->children() |
|
31
|
19 |
|
->scalarNode( 'url' ) |
|
32
|
19 |
|
->info( 'URL of the API endpoint like http://www.wikidata.org/w/api.php' ) |
|
33
|
19 |
|
->isRequired() |
|
34
|
19 |
|
->cannotBeEmpty() |
|
35
|
19 |
|
->end() |
|
36
|
19 |
|
->scalarNode( 'wikidataquery_url' ) |
|
37
|
19 |
|
->info( 'URL of the WikidataQuery API endpoint like http://wdq.wmflabs.org/api' ) |
|
38
|
19 |
|
->cannotBeEmpty() |
|
39
|
19 |
|
->end() |
|
40
|
19 |
|
->end() |
|
41
|
19 |
|
->end() |
|
42
|
19 |
|
->arrayNode( 'mongodb' ) |
|
43
|
19 |
|
->info( 'MongoDB backend configuration' ) |
|
44
|
19 |
|
->children() |
|
45
|
19 |
|
->scalarNode( 'server' ) |
|
46
|
19 |
|
->info( 'MongoDB server to use' ) |
|
47
|
19 |
|
->isRequired() |
|
48
|
19 |
|
->end() |
|
49
|
19 |
|
->scalarNode( 'database' ) |
|
50
|
19 |
|
->info( 'MongoDB database to use' ) |
|
51
|
19 |
|
->defaultValue( 'wikibase' ) |
|
52
|
19 |
|
->end() |
|
53
|
19 |
|
->end() |
|
54
|
19 |
|
->end() |
|
55
|
19 |
|
->arrayNode( 'cache' ) |
|
56
|
19 |
|
->info( 'Cache support configuration' ) |
|
57
|
19 |
|
->children() |
|
58
|
19 |
|
->integerNode( 'lifetime' ) |
|
59
|
19 |
|
->info( 'Cache life time' ) |
|
60
|
19 |
|
->defaultValue( 0 ) |
|
61
|
19 |
|
->end() |
|
62
|
19 |
|
->arrayNode( 'array' ) |
|
63
|
19 |
|
->info( 'Use PHP array cache' ) |
|
64
|
19 |
|
->canBeEnabled() |
|
65
|
19 |
|
->end() |
|
66
|
19 |
|
->arrayNode( 'memcached' ) |
|
67
|
19 |
|
->info( 'Use Memcached' ) |
|
68
|
19 |
|
->canBeEnabled() |
|
69
|
19 |
|
->children() |
|
70
|
19 |
|
->scalarNode( 'host' ) |
|
71
|
19 |
|
->defaultValue( 'localhost' ) |
|
72
|
19 |
|
->end() |
|
73
|
19 |
|
->integerNode( 'port' ) |
|
74
|
19 |
|
->defaultValue( 11211 ) |
|
75
|
19 |
|
->end() |
|
76
|
19 |
|
->end() |
|
77
|
19 |
|
->end() |
|
78
|
19 |
|
->end() |
|
79
|
19 |
|
->end() |
|
80
|
19 |
|
->variableNode( 'options' ) |
|
81
|
19 |
|
->info( 'EntityStore options configuration' ) |
|
82
|
19 |
|
->defaultValue( [] ) |
|
83
|
19 |
|
->end() |
|
84
|
19 |
|
->end(); |
|
85
|
|
|
|
|
86
|
19 |
|
return $treeBuilder; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|