Lines
0.00%
0 / 13
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Topics | 0.00% | 0 / 13 | 0.00% | 0 / 1 | 42 | 0.00% | 0 / 1 | |||
| runImport | 0.00% | 0 / 13 | 0.00% | 0 / 1 | 42 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsdldb\Importer\MySQL; | |
| 4 | ||
| 5 | class Topics extends Base | |
| 6 | { | |
| 7 | /** @var class-string<\BO\Zmsdldb\Importer\MySQL\Entity\Base>|null */ | |
| 8 | protected ?string $entityClass = \BO\Zmsdldb\Importer\MySQL\Entity\Topic::class; | |
| 9 | ||
| 10 | /** @psalm-api */ | |
| 11 | #[\Override] | |
| 12 | public function runImport(): bool | |
| 13 | { | |
| 14 | try { | |
| 15 | if ($this->needsUpdate()) { | |
| 16 | foreach ($this->getIterator() as $topic) { | |
| 17 | if (!is_array($topic)) { | |
| 18 | continue; | |
| 19 | } | |
| 20 | $topic = $this->createEntity($topic); | |
| 21 | $this->removeEntityFromCurrentList((int) $topic->get('id')); | |
| 22 | $topic->save(); | |
| 23 | } | |
| 24 | } | |
| 25 | foreach ($this->getCurrentEntitys() as $entityToDelete) { | |
| 26 | $entityToDelete->delete(); | |
| 27 | } | |
| 28 | $this->saveMetaObject(); | |
| 29 | } catch (\Exception $e) { | |
| 30 | throw $e; | |
| 31 | } | |
| 32 | ||
| 33 | return true; | |
| 34 | } | |
| 35 | } |