-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathConfiguration.php
93 lines (85 loc) · 4.25 KB
/
Configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
declare(strict_types=1);
namespace Meilisearch\Bundle\DependencyInjection;
use Meilisearch\Bundle\Searchable;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('meili_search');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
->scalarNode('url')->defaultValue('http://localhost:7700')->end()
->scalarNode('api_key')->end()
->scalarNode('prefix')
->defaultNull()
->end()
->integerNode('nbResults')
->defaultValue(20)
->end()
->integerNode('batchSize')
->defaultValue(500)
->end()
->arrayNode('doctrineSubscribedEvents')
->prototype('scalar')->end()
->defaultValue(['postPersist', 'postUpdate', 'preRemove'])
->end()
->scalarNode('serializer')
->defaultValue('serializer')
->end()
->arrayNode('indices')
->arrayPrototype()
->children()
->scalarNode('name')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('class')
->isRequired()
->cannotBeEmpty()
->end()
->booleanNode('enable_serializer_groups')
->info('When set to true, it will call normalize method with an extra groups parameter "groups" => [Searchable::NORMALIZATION_GROUP]')
->defaultFalse()
->end()
->arrayNode('serializer_groups')
->info('When setting a different value, normalization will be called with it instead of "Searchable::NORMALIZATION_GROUP".')
->defaultValue([Searchable::NORMALIZATION_GROUP])
->scalarPrototype()->end()
->end()
->scalarNode('index_if')
->info('Property accessor path (like method or property name) used to decide if an entry should be indexed.')
->defaultNull()
->end()
->scalarNode('data_provider')
->info('Method of the entity repository called when the meilisearch:import command is invoked.')
->defaultNull()
->end()
->arrayNode('settings')
->info('Configure indices settings, see: https://www.meilisearch.com/docs/reference/api/settings')
->beforeNormalization()
->always()
->then(static function (array $value) {
$stringSettings = ['distinctAttribute', 'proximityPrecision', 'searchCutoffMs'];
foreach ($stringSettings as $setting) {
if (isset($value[$setting]) && !\is_array($value[$setting])) {
$value[$setting] = (array) $value[$setting];
}
}
return $value;
})
->end()
->arrayPrototype()
->variablePrototype()->end()
->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
}
}