Lines
0.00%
0 / 20
Functions and Methods
0.00%
0 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Search | 0.00% | 0 / 20 | 0.00% | 0 / 4 | 110 | 0.00% | 0 / 1 | |||
| postSetupFields | 0.00% | 0 / 4 | 0.00% | 0 / 1 | 20 | |||||
| postSetup | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| deleteEntity | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 6 | |||||
| clearEntity | 0.00% | 0 / 5 | 0.00% | 0 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsdldb\Importer\MySQL\Entity; | |
| 4 | ||
| 5 | class Search extends Base | |
| 6 | { | |
| 7 | protected array $fieldMapping = [ | |
| 8 | 'object_id' => 'object_id', | |
| 9 | 'locale' => 'locale', | |
| 10 | 'entity_type' => 'entity_type', | |
| 11 | 'search_type' => 'search_type', | |
| 12 | 'search_value' => 'search_value', | |
| 13 | ]; | |
| 14 | ||
| 15 | #[\Override] | |
| 16 | public function postSetupFields(): void | |
| 17 | { | |
| 18 | if (isset($this->fields['search_value']) && !empty($this->fields['search_value'])) { | |
| 19 | if (is_array($this->fields['search_value'])) { | |
| 20 | $this->fields['search_value'] = implode(', ', array_filter($this->fields['search_value'])); | |
| 21 | } | |
| 22 | } | |
| 23 | $this->fields['search_value'] = trim($this->fields['search_value'] ?? ''); | |
| 24 | } | |
| 25 | ||
| 26 | #[\Override] | |
| 27 | public function postSetup(): void | |
| 28 | { | |
| 29 | $val = trim($this->fields['search_value']); | |
| 30 | if (empty($val)) { | |
| 31 | $this->setStatus(static::STATUS_OLD); | |
| 32 | } | |
| 33 | } | |
| 34 | ||
| 35 | #[\Override] | |
| 36 | public function deleteEntity(): void | |
| 37 | { | |
| 38 | try { | |
| 39 | $this->deleteWith( | |
| 40 | array_combine( | |
| 41 | ['object_id', 'locale', 'entity_type'], | |
| 42 | array_values($this->get(['object_id', 'locale', 'entity_type'])) | |
| 43 | ) | |
| 44 | ); | |
| 45 | } catch (\Exception $e) { | |
| 46 | throw $e; | |
| 47 | } | |
| 48 | } | |
| 49 | ||
| 50 | #[\Override] | |
| 51 | public function clearEntity(array $addWhere = []): void | |
| 52 | { | |
| 53 | try { | |
| 54 | #print_r(static::class); | |
| 55 | $this->deleteWith( | |
| 56 | array_combine(['entity_type', 'locale'], array_values($this->get(['entity_type', 'locale']))) | |
| 57 | ); | |
| 58 | } catch (\Exception $e) { | |
| 59 | throw $e; | |
| 60 | } | |
| 61 | } | |
| 62 | } |