Lines
0.00%
0 / 18
Functions and Methods
0.00%
0 / 3
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| TopicLinks | 0.00% | 0 / 18 | 0.00% | 0 / 3 | 56 | 0.00% | 0 / 1 | |||
| postSetupFields | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 12 | |||||
| clearEntity | 0.00% | 0 / 5 | 0.00% | 0 / 1 | 6 | |||||
| deleteEntity | 0.00% | 0 / 5 | 0.00% | 0 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsdldb\Importer\MySQL\Entity; | |
| 4 | ||
| 5 | class TopicLinks extends Base | |
| 6 | { | |
| 7 | protected array $fieldMapping = [ | |
| 8 | 'topic_id' => 'topic_id', | |
| 9 | 'name' => 'name', | |
| 10 | 'locale' => 'locale', | |
| 11 | 'rank' => 'rank', | |
| 12 | 'link' => 'url', | |
| 13 | 'search' => 'search', | |
| 14 | 'highlight' => 'highlight', | |
| 15 | #'meta.keywords' => 'keywords', | |
| 16 | #'meta.titles' => 'titles', | |
| 17 | 'meta' => 'meta_json', | |
| 18 | '__RAW__' => 'data_json' | |
| 19 | ]; | |
| 20 | ||
| 21 | #[\Override] | |
| 22 | public function postSetupFields(): void | |
| 23 | { | |
| 24 | $searchValues = [$this->get('name')]; | |
| 25 | /* | |
| 26 | if (array_key_exists('titles', ($this->fields['meta'] ?? [])) && !empty($this->fields['meta']['titles'])) { | |
| 27 | $titels = $this->fields['meta']['titles']; | |
| 28 | if (is_string($this->fields['meta']['titles'])) { | |
| 29 | $titels = explode(',', $this->fields['meta']['titles']); | |
| 30 | } | |
| 31 | $titels = array_filter($titels); | |
| 32 | array_push($searchValues, ...$titels); | |
| 33 | } | |
| 34 | */ | |
| 35 | ||
| 36 | $keywords = $this->get('meta.keywords'); | |
| 37 | if (!empty($keywords)) { | |
| 38 | if (is_string($keywords)) { | |
| 39 | $keywords = explode(',', $keywords); | |
| 40 | } | |
| 41 | $keywords = array_filter($keywords); | |
| 42 | array_push($searchValues, ...$keywords); | |
| 43 | } | |
| 44 | ||
| 45 | $this->fields['search'] = implode(', ', $searchValues); | |
| 46 | } | |
| 47 | ||
| 48 | #[\Override] | |
| 49 | public function clearEntity(array $addWhere = []): void | |
| 50 | { | |
| 51 | try { | |
| 52 | $this->deleteWith( | |
| 53 | ['locale' => $this->get('meta.locale')] | |
| 54 | ); | |
| 55 | } catch (\Exception $e) { | |
| 56 | throw $e; | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | #[\Override] | |
| 61 | public function deleteEntity(): void | |
| 62 | { | |
| 63 | try { | |
| 64 | $this->deleteWith( | |
| 65 | array_combine(['topic_id', 'locale'], array_values($this->get('topic_id', 'locale'))) | |
| 66 | ); | |
| 67 | } catch (\Exception $e) { | |
| 68 | throw $e; | |
| 69 | } | |
| 70 | } | |
| 71 | } |