forked from FriendsOfSymfony/FOSElasticaBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexTemplateConfig.php
More file actions
77 lines (66 loc) · 1.89 KB
/
Copy pathIndexTemplateConfig.php
File metadata and controls
77 lines (66 loc) · 1.89 KB
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
<?php
declare(strict_types=1);
/*
* This file is part of the FOSElasticaBundle package.
*
* (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\ElasticaBundle\Configuration;
/**
* Index template configuration class.
*
* @author Dmitry Balabka <dmitry.balabka@intexsys.lv>
*
* @phpstan-import-type TConfig from IndexConfigInterface
*/
class IndexTemplateConfig implements IndexConfigInterface
{
use IndexConfigTrait;
/**
* Index name pattern.
*
* @var list<non-empty-string>
*/
private array $indexPatterns;
/**
* The priority of the index template.
*/
private int $priority;
/**
* Constructor expects an array as generated by the Container Configuration builder.
*
* @phpstan-param TConfig $config
*/
public function __construct(array $config)
{
$this->elasticSearchName = $config['elasticsearch_name'] ?? $config['name'];
$this->name = $config['name'];
$this->settings = $config['settings'] ?? [];
$this->config = $config['config'];
$this->mapping = $config['mapping'];
$this->priority = $config['priority'];
if (!isset($config['index_patterns']) || !\is_array($config['index_patterns']) || \count($config['index_patterns']) < 1) {
throw new \InvalidArgumentException('Index patterns value(s) must be set');
}
$this->indexPatterns = $config['index_patterns'];
}
/**
* Gets index name pattern.
*
* @return list<non-empty-string>
*/
public function getIndexPatterns(): array
{
return $this->indexPatterns;
}
/**
* Gets index template priority.
*/
public function getPriority(): int
{
return $this->priority;
}
}