Lines
0.00%
0 / 73
Methods
0.00%
0 / 10
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | ||
| runImport | 0.00% | 0 / 4 | 0.00% | 0 / 1 | 6 | ||
| preImport | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| postImport | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| [BO\Zmsdldb\Importer\Base] setLocaleList | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| [BO\Zmsdldb\Importer\Base] __call | 0.00% | 0 / 13 | 0.00% | 0 / 1 | 30 | ||
| [BO\Zmsdldb\Importer\Base] clearDatabase | 0.00% | 0 / 20 | 0.00% | 0 / 1 | 56 | ||
| [BO\Zmsdldb\Importer\Base] importSettings | 0.00% | 0 / 10 | 0.00% | 0 / 1 | 6 | ||
| [BO\Zmsdldb\Importer\Base] importTopics | 0.00% | 0 / 10 | 0.00% | 0 / 1 | 6 | ||
| [BO\Zmsdldb\Importer\Base] importAuthorities | 0.00% | 0 / 10 | 0.00% | 0 / 1 | 6 | ||
| 14 | class MySQL extends Base | |
| 15 | { | |
| 16 | public function __construct(MySQLAccess $mysqlAccess, FileAccess $fileAccess, int $options = 0) | |
| 17 | { | |
| 18 | try { | |
| 19 | parent::__construct($mysqlAccess, $fileAccess, $options); | |
| 20 | } catch (\Exception $e) { | |
| 21 | throw $e; | |
| 22 | } | |
| 23 | } | |
| 24 | ||
| 25 | #[\Override] | |
| 26 | public function runImport(): void | |
| 27 | { | |
| 28 | try { | |
| 29 | parent::runImport(); | |
| 30 | } catch (\Exception $e) { | |
| 31 | $this->rollBack(); | |
| 32 | throw $e; | |
| 33 | } | |
| 34 | } | |
| 35 | #[\Override] | |
| 36 | public function preImport(): void | |
| 37 | { | |
| 38 | $this->beginTransaction(); | |
| 39 | } | |
| 40 | ||
| 41 | #[\Override] | |
| 42 | public function postImport(): void | |
| 43 | { | |
| 44 | $this->commit(); | |
| 45 | } | |
| 46 | } |
Inherited from BO\Zmsdldb\Importer\Base
| 51 | public function setLocaleList(array $localeList = ['de', 'en']): void | |
| 52 | { | |
| 53 | $this->localeList = $localeList; | |
| 54 | } |
| 61 | public function __call($method, $args = []) | |
| 62 | { | |
| 63 | try { | |
| 64 | if (preg_match('/get(?P<importer>[A-Za-z]+)Importer/', $method, $matches)) { | |
| 65 | $ImporterClass = static::class . '\\' . $matches['importer']; | |
| 66 | array_unshift($args, $this->getPDOAccess()); | |
| 67 | if ( | |
| 68 | !class_exists($ImporterClass) | |
| 69 | || !is_a($ImporterClass, \BO\Zmsdldb\Importer\MySQL\Base::class, true) | |
| 70 | ) { | |
| 71 | throw new \InvalidArgumentException( | |
| 72 | $ImporterClass . ' must extend \\BO\\Zmsdldb\\Importer\\MySQL\\Base' | |
| 73 | ); | |
| 74 | } | |
| 75 | /** @var class-string<\BO\Zmsdldb\Importer\MySQL\Base> $ImporterClass */ | |
| 76 | /** @psalm-suppress UnsafeInstantiation */ | |
| 77 | $instance = new $ImporterClass(...$args); | |
| 78 | return $instance; | |
| 79 | } | |
| 80 | throw new \BadMethodCallException('Method ' . $method . ' not found!'); | |
| 81 | } catch (\Exception $e) { | |
| 82 | throw $e; | |
| 83 | } | |
| 84 | } |
| 125 | public function clearDatabase() | |
| 126 | { | |
| 127 | try { | |
| 128 | if ( | |
| 129 | $this->checkOptionFlag(static::OPTION_CLEAR_ENTITIY_REFERENCES_TABLES) || | |
| 130 | $this->checkOptionFlag(static::OPTION_CLEAR_ENTITIY_TABLE) | |
| 131 | ) { | |
| 132 | /* | |
| 133 | $types = [ | |
| 134 | 'Services', | |
| 135 | 'Locations', | |
| 136 | 'Authorities', | |
| 137 | 'Topics', | |
| 138 | 'Settings' | |
| 139 | ]; | |
| 140 | */ | |
| 141 | $tablesToClear = []; | |
| 142 | ||
| 143 | foreach (array_keys($this->importTypes) as $type) { | |
| 144 | $importer = $this->__call( | |
| 145 | 'get' . $type . 'Importer', | |
| 146 | [ | |
| 147 | ['data' => [], 'hash' => ''], | |
| 148 | 'de', | |
| 149 | $this->getOptions() | |
| 150 | ] | |
| 151 | ); | |
| 152 | $entity = $importer->createEntity(['meta' => ['locale' => 'de']], false); | |
| 153 | $tablesToClear[$entity::getTableName()] = 1; | |
| 154 | ||
| 155 | foreach (array_values($entity->getReferenceMapping(true)) as $data) { | |
| 156 | $tablesToClear[call_user_func($data['class'] . '::getTableName')] = 1; | |
| 157 | } | |
| 158 | } | |
| 159 | ||
| 160 | foreach (array_flip($tablesToClear) as $table) { | |
| 161 | $this->getPDOAccess()->exec("DELETE FROM " . $table . " WHERE 1=1"); | |
| 162 | } | |
| 163 | } | |
| 164 | } catch (\Exception $e) { | |
| 165 | throw $e; | |
| 166 | } | |
| 167 | } |
| 174 | protected function importSettings() | |
| 175 | { | |
| 176 | try { | |
| 177 | $importer = $this->getSettingsImporter( | |
| 178 | $this->fileAccess->fromSetting()->getData(), | |
| 179 | 'de', | |
| 180 | $this->getOptions() | |
| 181 | ); | |
| 182 | $importer->preImport(); | |
| 183 | $importer->runImport(); | |
| 184 | $importer->postImport(); | |
| 185 | } catch (\Exception $e) { | |
| 186 | throw $e; | |
| 187 | } | |
| 188 | } |
| 195 | protected function importTopics() | |
| 196 | { | |
| 197 | try { | |
| 198 | $importer = $this->getTopicsImporter( | |
| 199 | $this->fileAccess->fromTopic('de')->getData(), | |
| 200 | 'de', | |
| 201 | $this->getOptions() | |
| 202 | ); | |
| 203 | $importer->preImport(); | |
| 204 | $importer->runImport(); | |
| 205 | $importer->postImport(); | |
| 206 | #$importer->clearEntity(); | |
| 207 | } catch (\Exception $e) { | |
| 208 | throw $e; | |
| 209 | } | |
| 210 | } |
| 217 | protected function importAuthorities() | |
| 218 | { | |
| 219 | try { | |
| 220 | $importer = $this->getAuthoritiesImporter( | |
| 221 | $this->fileAccess->fromAuthority('de')->getData(), | |
| 222 | 'de', | |
| 223 | $this->getOptions() | |
| 224 | ); | |
| 225 | $importer->preImport(); | |
| 226 | $importer->runImport(); | |
| 227 | $importer->postImport(); | |
| 228 | #$importer->clearEntity(); | |
| 229 | } catch (\Exception $e) { | |
| 230 | throw $e; | |
| 231 | } | |
| 232 | } |