Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
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 $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 | public function postSetupFields() |
16 | { |
17 | if (isset($this->fields['search_value']) && !empty($this->fields['search_value'])) { |
18 | if (is_array($this->fields['search_value'])) { |
19 | $this->fields['search_value'] = implode(', ', array_filter($this->fields['search_value'])); |
20 | } |
21 | } |
22 | $this->fields['search_value'] = trim($this->fields['search_value'] ?? ''); |
23 | } |
24 | |
25 | public function postSetup() |
26 | { |
27 | $val = trim($this->fields['search_value']); |
28 | if (empty($val)) { |
29 | $this->setStatus(static::STATUS_OLD); |
30 | } |
31 | } |
32 | |
33 | public function deleteEntity(): bool |
34 | { |
35 | try { |
36 | return $this->deleteWith( |
37 | array_combine( |
38 | ['object_id', 'locale', 'entity_type'], |
39 | array_values($this->get(['object_id', 'locale', 'entity_type'])) |
40 | ) |
41 | ); |
42 | } catch (\Exception $e) { |
43 | throw $e; |
44 | } |
45 | } |
46 | |
47 | public function clearEntity(array $addWhere = []): bool |
48 | { |
49 | try { |
50 | #print_r(static::class); |
51 | return $this->deleteWith( |
52 | array_combine(['entity_type', 'locale'], array_values($this->get(['entity_type', 'locale']))) |
53 | ); |
54 | } catch (\Exception $e) { |
55 | throw $e; |
56 | } |
57 | } |
58 | } |