1 | <?php |
||
26 | class MappingBuilder |
||
27 | { |
||
28 | /** |
||
29 | * Builds mappings for an entire index. |
||
30 | * |
||
31 | * @param IndexConfig $indexConfig |
||
32 | * |
||
33 | * @return array |
||
34 | */ |
||
35 | 5 | public function buildIndexMapping(IndexConfig $indexConfig) |
|
36 | { |
||
37 | 5 | $typeMappings = []; |
|
38 | 5 | foreach ($indexConfig->getTypes() as $typeConfig) { |
|
39 | 5 | $typeMappings[$typeConfig->getName()] = $this->buildTypeMapping($typeConfig); |
|
40 | } |
||
41 | |||
42 | 5 | $mapping = []; |
|
43 | 5 | if (!empty($typeMappings)) { |
|
44 | 5 | $mapping['mappings'] = $typeMappings; |
|
45 | } |
||
46 | // 'warmers' => $indexConfig->getWarmers(), |
||
47 | |||
48 | 5 | $settings = $indexConfig->getSettings(); |
|
49 | 5 | if (!empty($settings)) { |
|
50 | 2 | $mapping['settings'] = $settings; |
|
51 | } |
||
52 | |||
53 | 5 | return $mapping; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Builds mappings for a single type. |
||
58 | * |
||
59 | * @param TypeConfig $typeConfig |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | 6 | public function buildTypeMapping(TypeConfig $typeConfig) |
|
109 | |||
110 | /** |
||
111 | * Fixes any properties and applies basic defaults for any field that does not have |
||
112 | * required options. |
||
113 | * |
||
114 | * @param $properties |
||
115 | */ |
||
116 | 6 | private function fixProperties(&$properties) |
|
132 | } |
||
133 |