Lines
0.00%
0 / 127
Functions and Methods
0.00%
0 / 5
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Location | 0.00% | 0 / 127 | 0.00% | 0 / 5 | 90 | 0.00% | 0 / 1 | |||
| setupMapping | 0.00% | 0 / 105 | 0.00% | 0 / 1 | 2 | |||||
| preSetupFields | 0.00% | 0 / 4 | 0.00% | 0 / 1 | 2 | |||||
| preSetup | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 12 | |||||
| deleteEntity | 0.00% | 0 / 5 | 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 Location extends Base | |
| 6 | { | |
| 7 | protected array $fieldMapping = [ | |
| 8 | 'id' => 'id', | |
| 9 | 'name' => 'name', | |
| 10 | 'category.name' => 'category_name', | |
| 11 | 'category.identifier' => 'category_identifier', | |
| 12 | 'authority.id' => 'authority_id', | |
| 13 | 'authority.name' => 'authority_name', | |
| 14 | 'meta.locale' => 'locale', | |
| 15 | 'note' => 'note', | |
| 16 | 'category' => 'category_json', | |
| 17 | 'urgent' => 'urgent_json', | |
| 18 | 'opening_times' => 'opening_times_json', | |
| 19 | 'transit' => 'transit_json', | |
| 20 | 'payment_info' => 'payment_json', | |
| 21 | 'accessibility' => 'accessibility_json', | |
| 22 | 'appointment' => 'appointment_json', | |
| 23 | '__RAW__' => 'data_json' | |
| 24 | ]; | |
| 25 | /** | |
| 26 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength) | |
| 27 | */ | |
| 28 | #[\Override] | |
| 29 | protected function setupMapping(): void | |
| 30 | { | |
| 31 | $this->referanceMapping = [ | |
| 32 | 'name' => [ | |
| 33 | 'class' => Search::class, | |
| 34 | 'neededFields' => [ | |
| 35 | 'id' => 'object_id', | |
| 36 | 'meta.locale' => 'locale', | |
| 37 | 'name' => 'search_value' | |
| 38 | ], | |
| 39 | 'addFields' => [ | |
| 40 | 'entity_type' => static::getTableName(), | |
| 41 | 'search_type' => 'name' | |
| 42 | ], | |
| 43 | 'multiple' => false, | |
| 44 | 'clearFields' => [ | |
| 45 | 'entity_type' => static::getTableName(), | |
| 46 | 'locale' => $this->get('meta.locale') | |
| 47 | ], | |
| 48 | 'deleteFields' => [ | |
| 49 | 'object_id' => $this->get('id'), | |
| 50 | 'locale' => $this->get('meta.locale'), | |
| 51 | 'entity_type' => static::getTableName() | |
| 52 | ], | |
| 53 | 'selfAsArray' => true | |
| 54 | ], | |
| 55 | 'address' => [ | |
| 56 | 'class' => Search::class, | |
| 57 | 'neededFields' => [ | |
| 58 | 'id' => 'object_id', | |
| 59 | 'meta.locale' => 'locale', | |
| 60 | 'address' => 'search_value', | |
| 61 | ], | |
| 62 | 'addFields' => [ | |
| 63 | 'entity_type' => static::getTableName(), | |
| 64 | 'search_type' => 'address' | |
| 65 | ], | |
| 66 | 'deleteFields' => [ | |
| 67 | 'object_id' => $this->get('id'), | |
| 68 | 'locale' => $this->get('meta.locale'), | |
| 69 | 'entity_type' => static::getTableName() | |
| 70 | ], | |
| 71 | 'multiple' => false, | |
| 72 | 'clearFields' => [ | |
| 73 | 'entity_type' => static::getTableName(), | |
| 74 | 'locale' => $this->get('meta.locale') | |
| 75 | ], | |
| 76 | 'selfAsArray' => true | |
| 77 | ], | |
| 78 | 'meta.keywords' => [ | |
| 79 | 'class' => Search::class, | |
| 80 | 'neededFields' => [ | |
| 81 | 'id' => 'object_id', | |
| 82 | 'meta.locale' => 'locale', | |
| 83 | 'meta.keywords' => 'search_value', | |
| 84 | ], | |
| 85 | 'addFields' => [ | |
| 86 | 'entity_type' => static::getTableName(), | |
| 87 | 'search_type' => 'keywords' | |
| 88 | ], | |
| 89 | 'deleteFields' => [ | |
| 90 | 'object_id' => $this->get('id'), | |
| 91 | 'locale' => $this->get('meta.locale'), | |
| 92 | 'entity_type' => static::getTableName() | |
| 93 | ], | |
| 94 | 'multiple' => false, | |
| 95 | 'clearFields' => [ | |
| 96 | 'entity_type' => static::getTableName(), | |
| 97 | 'locale' => $this->get('meta.locale') | |
| 98 | ], | |
| 99 | 'selfAsArray' => true | |
| 100 | ], | |
| 101 | 'meta' => [ | |
| 102 | 'class' => Meta::class, | |
| 103 | 'neededFields' => [ | |
| 104 | 'id' => 'object_id', | |
| 105 | 'meta.locale' => 'locale' | |
| 106 | ], | |
| 107 | 'addFields' => [ | |
| 108 | 'type' => static::getTableName() | |
| 109 | ], | |
| 110 | 'deleteFields' => [ | |
| 111 | 'object_id' => $this->get('id'), | |
| 112 | 'locale' => $this->get('meta.locale'), | |
| 113 | 'type' => static::getTableName() | |
| 114 | ], | |
| 115 | 'multiple' => false, | |
| 116 | 'clearFields' => ['type' => static::getTableName(), 'locale' => $this->get('meta.locale')], | |
| 117 | ], | |
| 118 | 'contact' => [ | |
| 119 | 'class' => Contact::class, | |
| 120 | 'neededFields' => [ | |
| 121 | 'id' => 'object_id', | |
| 122 | 'meta.locale' => 'locale', | |
| 123 | 'address' => 'address', | |
| 124 | 'geo' => 'geo' | |
| 125 | ], | |
| 126 | 'deleteFields' => [ | |
| 127 | 'object_id' => $this->get('id'), | |
| 128 | 'locale' => $this->get('meta.locale') | |
| 129 | ], | |
| 130 | 'addFields' => [], | |
| 131 | 'multiple' => false, | |
| 132 | 'selfAsArray' => true, | |
| 133 | 'clearFields' => ['locale' => $this->get('meta.locale')], | |
| 134 | ], | |
| 135 | ]; | |
| 136 | } | |
| 137 | ||
| 138 | #[\Override] | |
| 139 | public function preSetupFields(): void | |
| 140 | { | |
| 141 | #$this->dataRaw['payment'] = [ | |
| 142 | # 'payment_info' => $this->dataRaw['payment'], | |
| 143 | # 'paymentcode' => ($this->dataRaw['paymentcode'] ?? null) | |
| 144 | #]; | |
| 145 | $this->dataRaw['payment_info'] = [ | |
| 146 | 'info' => $this->dataRaw['payment'], | |
| 147 | 'code' => ($this->dataRaw['paymentcode'] ?? null) | |
| 148 | ]; | |
| 149 | #unset($this->dataRaw['paymentcode']); | |
| 150 | } | |
| 151 | ||
| 152 | #[\Override] | |
| 153 | public function preSetup(): void | |
| 154 | { | |
| 155 | try { | |
| 156 | $this->setStatus(static::STATUS_OLD); | |
| 157 | if ($this->entityNeedsUpdate()) { | |
| 158 | $this->setStatus(static::STATUS_NEW); | |
| 159 | $this->setupFields(); | |
| 160 | $this->deleteEntity(); | |
| 161 | $this->deleteReferences(); | |
| 162 | } | |
| 163 | } catch (\Exception $e) { | |
| 164 | throw $e; | |
| 165 | } | |
| 166 | } | |
| 167 | ||
| 168 | #[\Override] | |
| 169 | public function deleteEntity(): void | |
| 170 | { | |
| 171 | try { | |
| 172 | $this->deleteWith( | |
| 173 | array_combine(['id', 'locale'], array_values($this->get(['id', 'meta.locale']))) | |
| 174 | ); | |
| 175 | } catch (\Exception $e) { | |
| 176 | throw $e; | |
| 177 | } | |
| 178 | } | |
| 179 | ||
| 180 | #[\Override] | |
| 181 | public function clearEntity(array $addWhere = []): void | |
| 182 | { | |
| 183 | try { | |
| 184 | $this->deleteWith( | |
| 185 | ['locale' => $this->get('meta.locale')] | |
| 186 | ); | |
| 187 | } catch (\Exception $e) { | |
| 188 | throw $e; | |
| 189 | } | |
| 190 | } | |
| 191 | } |