Conditions | 5 |
Paths | 5 |
Total Lines | 31 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types = 1); |
||
25 | public function getFieldsToIndex(DataObject $dataObject): array |
||
26 | { |
||
27 | $indexes = new Indexes(); |
||
28 | $indices = $indexes->getIndexes(); |
||
29 | |||
30 | $payload = []; |
||
31 | |||
32 | /** @var \Suilven\FreeTextSearch\Index $indice */ |
||
33 | foreach ($indices as $indice) { |
||
34 | $indicePayload = []; |
||
35 | |||
36 | $clazz = $indice->getClass(); |
||
37 | $classes = $dataObject->getClassAncestry(); |
||
38 | |||
39 | foreach ($classes as $indiceClass) { |
||
40 | if ($indiceClass !== $clazz) { |
||
41 | continue; |
||
42 | } |
||
43 | |||
44 | $fields = $indice->getFields(); |
||
45 | foreach ($fields as $field) { |
||
46 | $value = $dataObject->$field; |
||
47 | $indicePayload[$field] = $value; |
||
48 | } |
||
49 | } |
||
50 | $payload[$indice->getName()] = $indicePayload; |
||
51 | } |
||
52 | |||
53 | // @todo a possible mutator, specific to different search engines, may be required here |
||
54 | |||
55 | return $payload; |
||
56 | } |
||
58 |