1 | <?php |
||
11 | class DatabaseTermIdsAcquirer implements TermIdsAcquirer { |
||
12 | |||
13 | const TABLE_TEXT = 'wbt_text'; |
||
14 | const TABLE_TEXT_IN_LANG = 'wbt_text_in_lang'; |
||
15 | const TABLE_TERM_IN_LANG = 'wbt_term_in_lang'; |
||
16 | |||
17 | /** |
||
18 | * @var ILoadBalancer |
||
19 | */ |
||
20 | private $loadBalancer; |
||
21 | |||
22 | /** |
||
23 | * @var TypeIdsAcquirer |
||
24 | */ |
||
25 | private $typeIdsAcquirer; |
||
26 | |||
27 | public function __construct( |
||
28 | ILoadBalancer $loadBalancer, |
||
29 | TypeIdsAcquirer $typeIdsAcquirer |
||
30 | ) { |
||
31 | $this->loadBalancer = $loadBalancer; |
||
32 | $this->typeIdsAcquirer = $typeIdsAcquirer; |
||
33 | } |
||
34 | |||
35 | public function acquireTermIds( array $termsArray ): array { |
||
41 | |||
42 | /** |
||
43 | * replace root keys containing type names in termsArray |
||
44 | * with their respective ids in wbt_type table |
||
45 | * |
||
46 | * @param array $termsArray terms per type per language: |
||
47 | * [ |
||
48 | * 'type1' => [ ... ], |
||
49 | * 'type2' => [ ... ], |
||
50 | * ... |
||
51 | * ] |
||
52 | * |
||
53 | * @return array |
||
54 | * [ |
||
55 | * <typeId1> => [ ... ], |
||
56 | * <typeId2> => [ ... ], |
||
57 | * ... |
||
58 | * ] |
||
59 | */ |
||
60 | private function mapToTypeIds( array $termsArray ) { |
||
70 | |||
71 | /** |
||
72 | * replace text at termsArray leaves with their ids in wbt_text table |
||
73 | * and return resulting array |
||
74 | * |
||
75 | * @param array $termsArray terms per type per language: |
||
76 | * [ |
||
77 | * 'type' => [ |
||
78 | * [ 'language' => 'term' | [ 'term1', 'term2', ... ] ], ... |
||
79 | * ], ... |
||
80 | * ] |
||
81 | * |
||
82 | * @return array |
||
83 | * [ |
||
84 | * 'type' => [ |
||
85 | * [ 'language' => [ <textId1>, <textId2>, ... ] ], ... |
||
86 | * ], ... |
||
87 | * ] |
||
88 | */ |
||
89 | private function mapToTextIds( array $termsArray ) { |
||
104 | |||
105 | private function acquireTextIds( array $texts ) { |
||
123 | |||
124 | /** |
||
125 | * replace ( lang => [ textId, ... ] ) entries with their respective ids |
||
126 | * in wbt_text_in_lang table and return resulting array |
||
127 | * |
||
128 | * @param array $termsArray text ids per type per langauge |
||
129 | * [ |
||
130 | * 'type' => [ |
||
131 | * [ 'language' => [ <textId1>, <textId2>, ... ] ], ... |
||
132 | * ], ... |
||
133 | * ] |
||
134 | * |
||
135 | * @return array |
||
136 | * [ |
||
137 | * 'type' => [ <textInLangId1>, <textInLangId2>, ... ], |
||
138 | * ... |
||
139 | * ] |
||
140 | */ |
||
141 | private function mapToTextInLangIds( array $termsArray ) { |
||
173 | |||
174 | private function acquireTextInLangIds( array $langTextIds ) { |
||
195 | |||
196 | /** |
||
197 | * replace root ( type => [ textInLangId, ... ] ) entries with their respective ids |
||
198 | * in wbt_term_in_lang table and return resulting array |
||
199 | * |
||
200 | * @param array $termsArray text in lang ids per type |
||
201 | * [ |
||
202 | * 'type' => [ <textInLangId1>, <textInLangId2>, ... ], |
||
203 | * ... |
||
204 | * ] |
||
205 | * |
||
206 | * @return array |
||
207 | * [ |
||
208 | * <termInLang1>, |
||
209 | * <termInLang2>, |
||
210 | * ... |
||
211 | * ] |
||
212 | */ |
||
213 | private function mapToTermInLangIds( array $termsArray ) { |
||
239 | |||
240 | private function acquireTermInLangIds( array $typeTextInLangIds ) { |
||
264 | |||
265 | } |
||
266 |