| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types = 1); |
||
| 14 | public function index(\SilverStripe\ORM\DataObject $dataObject): void |
||
| 15 | { |
||
| 16 | $payload = $this->getIndexablePayload($dataObject); |
||
| 17 | $coreClient = new Client(); |
||
| 18 | $client = $coreClient->getConnection(); |
||
| 19 | |||
| 20 | $indexNames = \array_keys($payload); |
||
| 21 | foreach ($indexNames as $indexName) { |
||
| 22 | $indexPayload = $payload[$indexName]; |
||
| 23 | |||
| 24 | // skip empty payloads |
||
| 25 | if ($indexPayload === []) { |
||
| 26 | continue; |
||
| 27 | } |
||
| 28 | |||
| 29 | // @todo fix parent id indexing |
||
| 30 | unset($indexPayload['ParentID']); |
||
| 31 | |||
| 32 | $manticoreIndex = new \Manticoresearch\Index($client, $indexName); |
||
| 33 | $manticoreIndex->replaceDocument($indexPayload, $dataObject->ID); |
||
| 34 | } |
||
| 37 |