1 | <?php |
||
10 | class FieldFormatter |
||
11 | { |
||
12 | /** |
||
13 | * @param $mappings |
||
14 | * @param $associationMappings |
||
15 | * |
||
16 | * @return mixed |
||
17 | */ |
||
18 | public function formatMappingsWithRelations($mappings, $associationMappings) |
||
19 | { |
||
20 | $formattedMappings = $this->formatMappings($mappings); |
||
21 | |||
22 | return $this->formatRelationMappings($formattedMappings, $associationMappings); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param $mappings |
||
27 | * |
||
28 | * @return mixed |
||
29 | */ |
||
30 | public function formatMappings($mappings) |
||
31 | { |
||
32 | $types = $this->getTypes(); |
||
33 | |||
34 | foreach ($mappings as $key => $mapping) { |
||
35 | $mappings[$key] = $types[$mappings[$key]['type']]; |
||
36 | } |
||
37 | |||
38 | return $mappings; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param $mappings |
||
43 | * @param $associationMappings |
||
44 | * |
||
45 | * @return mixed |
||
46 | */ |
||
47 | protected function formatRelationMappings($mappings, $associationMappings) |
||
59 | |||
60 | /** |
||
61 | * @return array |
||
62 | */ |
||
63 | protected function getTypes() |
||
73 | } |
||
74 |