1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ONGR package. |
5
|
|
|
* |
6
|
|
|
* (c) NFQ Technologies UAB <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace ONGR\ElasticsearchBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Psr\Log\LogLevel; |
15
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
16
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
17
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
18
|
|
|
|
19
|
|
|
class Configuration implements ConfigurationInterface |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
const ONGR_CACHE_CONFIG = 'ongr.esb.cache'; |
23
|
|
|
const ONGR_SOURCE_DIR = 'ongr.esb.source_dir'; |
24
|
|
|
const ONGR_PROFILER_CONFIG = 'ongr.esb.profiler'; |
25
|
|
|
const ONGR_LOGGER_CONFIG = 'ongr.esb.logger'; |
26
|
|
|
const ONGR_ANALYSIS_CONFIG = 'ongr.esb.analysis'; |
27
|
|
|
const ONGR_INDEXES = 'ongr.esb.indexes'; |
28
|
|
|
const ONGR_DEFAULT_INDEX = 'ongr.esb.default_index'; |
29
|
|
|
const ONGR_INDEXES_OVERRIDE = 'ongr.esb.indexes_override'; |
30
|
|
|
|
31
|
|
|
public function getConfigTreeBuilder() |
32
|
|
|
{ |
33
|
|
|
$treeBuilder = new TreeBuilder(); |
34
|
|
|
$rootNode = $treeBuilder->root('ongr_elasticsearch'); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$rootNode |
37
|
|
|
->children() |
38
|
|
|
|
39
|
|
|
->booleanNode('cache') |
40
|
|
|
->info( |
41
|
|
|
'Enables the cache handler to store important data to the cache. '. |
42
|
|
|
'Default value is kernel.debug parameter.' |
43
|
|
|
) |
44
|
|
|
->end() |
45
|
|
|
|
46
|
|
|
->booleanNode('profiler') |
47
|
|
|
->info( |
48
|
|
|
'Enables Symfony profiler for the elasticsearch queries debug.'. |
49
|
|
|
'Default value is kernel.debug parameter. ' |
50
|
|
|
) |
51
|
|
|
->end() |
52
|
|
|
|
53
|
|
|
->booleanNode('logger') |
54
|
|
|
->defaultTrue() |
55
|
|
|
->info( |
56
|
|
|
'Enables executed queries logging. Log file names are the same as index.' |
57
|
|
|
) |
58
|
|
|
->end() |
59
|
|
|
|
60
|
|
|
->arrayNode('source_directories') |
61
|
|
|
->prototype('scalar')->end() |
62
|
|
|
->defaultValue(['/src']) |
63
|
|
|
->info( |
64
|
|
|
'If your project has different than `/src` source directory, or several of them,' . |
65
|
|
|
'you can specify them here to look automatically for ES documents.' |
66
|
|
|
) |
67
|
|
|
->end() |
68
|
|
|
|
69
|
|
|
->arrayNode('indexes') |
70
|
|
|
->defaultValue([]) |
71
|
|
|
->info( |
72
|
|
|
'In case you want to override index settings defined in the annotation.' . |
73
|
|
|
' e.g. use env variables instead.' |
74
|
|
|
) |
75
|
|
|
->prototype('variable')->end() |
76
|
|
|
->end() |
77
|
|
|
|
78
|
|
|
->append($this->getAnalysisNode()) |
79
|
|
|
|
80
|
|
|
->end(); |
81
|
|
|
|
82
|
|
|
return $treeBuilder; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
private function getAnalysisNode(): NodeDefinition |
86
|
|
|
{ |
87
|
|
|
$builder = new TreeBuilder(); |
88
|
|
|
$node = $builder->root('analysis'); |
|
|
|
|
89
|
|
|
|
90
|
|
|
$node |
91
|
|
|
->info('Defines analyzers, normalizers, tokenizers and filters') |
92
|
|
|
->addDefaultsIfNotSet() |
93
|
|
|
->children() |
94
|
|
|
->arrayNode('tokenizer') |
95
|
|
|
->defaultValue([]) |
96
|
|
|
->prototype('variable')->end() |
97
|
|
|
->end() |
98
|
|
|
->arrayNode('filter') |
99
|
|
|
->defaultValue([]) |
100
|
|
|
->prototype('variable')->end() |
101
|
|
|
->end() |
102
|
|
|
->arrayNode('analyzer') |
103
|
|
|
->defaultValue([]) |
104
|
|
|
->prototype('variable')->end() |
105
|
|
|
->end() |
106
|
|
|
->arrayNode('normalizer') |
107
|
|
|
->defaultValue([]) |
108
|
|
|
->prototype('variable')->end() |
109
|
|
|
->end() |
110
|
|
|
->arrayNode('char_filter') |
111
|
|
|
->defaultValue([]) |
112
|
|
|
->prototype('variable')->end() |
113
|
|
|
->end() |
114
|
|
|
->end(); |
115
|
|
|
|
116
|
|
|
return $node; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.