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
|
|
|
|
34
|
|
|
$treeBuilder = new TreeBuilder('ongr_elasticsearch'); |
35
|
|
|
|
36
|
|
|
if (method_exists($treeBuilder, 'getRootNode')) { |
37
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
38
|
|
|
} else { |
39
|
|
|
// BC layer for symfony/config 4.1 and older |
40
|
|
|
$rootNode = $treeBuilder->root('ongr_elasticsearch'); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$rootNode |
44
|
|
|
->children() |
45
|
|
|
|
46
|
|
|
->booleanNode('cache') |
47
|
|
|
->info( |
48
|
|
|
'Enables the cache handler to store important data to the cache. '. |
49
|
|
|
'Default value is kernel.debug parameter.' |
50
|
|
|
) |
51
|
|
|
->end() |
52
|
|
|
|
53
|
|
|
->booleanNode('profiler') |
54
|
|
|
->info( |
55
|
|
|
'Enables Symfony profiler for the elasticsearch queries debug.'. |
56
|
|
|
'Default value is kernel.debug parameter. ' |
57
|
|
|
) |
58
|
|
|
->end() |
59
|
|
|
|
60
|
|
|
->booleanNode('logger') |
61
|
|
|
->defaultTrue() |
62
|
|
|
->info( |
63
|
|
|
'Enables executed queries logging. Log file names are the same as index.' |
64
|
|
|
) |
65
|
|
|
->end() |
66
|
|
|
|
67
|
|
|
->arrayNode('source_directories') |
68
|
|
|
->prototype('scalar')->end() |
69
|
|
|
->defaultValue(['/src']) |
70
|
|
|
->info( |
71
|
|
|
'If your project has different than `/src` source directory, or several of them,' . |
72
|
|
|
'you can specify them here to look automatically for ES documents.' |
73
|
|
|
) |
74
|
|
|
->end() |
75
|
|
|
|
76
|
|
|
->arrayNode('indexes') |
77
|
|
|
->defaultValue([]) |
78
|
|
|
->useAttributeAsKey('namespace') |
79
|
|
|
->info( |
80
|
|
|
'In case you want to override index settings defined in the annotation.' . |
81
|
|
|
' e.g. use env variables instead.' |
82
|
|
|
) |
83
|
|
|
->prototype('variable')->end() |
84
|
|
|
->end() |
85
|
|
|
|
86
|
|
|
->append($this->getAnalysisNode()) |
87
|
|
|
|
88
|
|
|
->end(); |
89
|
|
|
|
90
|
|
|
return $treeBuilder; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
private function getAnalysisNode(): NodeDefinition |
94
|
|
|
{ |
95
|
|
|
$builder = new TreeBuilder('analysis'); |
96
|
|
|
|
97
|
|
|
if (method_exists($builder, 'getRootNode')) { |
98
|
|
|
$node = $builder->getRootNode(); |
99
|
|
|
} else { |
100
|
|
|
// BC layer for symfony/config 4.1 and older |
101
|
|
|
$node = $builder->root('analysis'); |
|
|
|
|
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
$node |
106
|
|
|
->info('Defines analyzers, normalizers, tokenizers and filters') |
107
|
|
|
->addDefaultsIfNotSet() |
108
|
|
|
->children() |
109
|
|
|
->arrayNode('tokenizer') |
110
|
|
|
->defaultValue([]) |
111
|
|
|
->prototype('variable')->end() |
112
|
|
|
->end() |
113
|
|
|
->arrayNode('filter') |
114
|
|
|
->defaultValue([]) |
115
|
|
|
->prototype('variable')->end() |
116
|
|
|
->end() |
117
|
|
|
->arrayNode('analyzer') |
118
|
|
|
->defaultValue([]) |
119
|
|
|
->prototype('variable')->end() |
120
|
|
|
->end() |
121
|
|
|
->arrayNode('normalizer') |
122
|
|
|
->defaultValue([]) |
123
|
|
|
->prototype('variable')->end() |
124
|
|
|
->end() |
125
|
|
|
->arrayNode('char_filter') |
126
|
|
|
->defaultValue([]) |
127
|
|
|
->prototype('variable')->end() |
128
|
|
|
->end() |
129
|
|
|
->end(); |
130
|
|
|
|
131
|
|
|
return $node; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.