* @param list > $rows * @param array $reportMap * @throws Exception */
(string $uid, array $rows, array $reportMap)
| 473 | * @throws Exception |
| 474 | */ |
| 475 | private function importPanoramas(string $uid, array $rows, array $reportMap): void { |
| 476 | $idMap = []; |
| 477 | |
| 478 | foreach ($rows as $row) { |
| 479 | if (!isset($row['id'])) { |
| 480 | continue; |
| 481 | } |
| 482 | |
| 483 | $oldId = (int)$row['id']; |
| 484 | $pages = $this->remapPanoramaPages((string)($row['pages'] ?? '[]'), $reportMap); |
| 485 | |
| 486 | $newId = $this->insertAndReturnId('analytics_panorama', [ |
| 487 | 'user_id' => $uid, |
| 488 | 'name' => $row['name'] ?? '', |
| 489 | 'type' => isset($row['type']) ? (int)$row['type'] : 0, |
| 490 | 'parent' => 0, |
| 491 | 'pages' => $pages, |
| 492 | ]); |
| 493 | $idMap[$oldId] = $newId; |
| 494 | } |
| 495 | |
| 496 | foreach ($rows as $row) { |
| 497 | if (!isset($row['id']) || !isset($idMap[(int)$row['id']])) { |
| 498 | continue; |
| 499 | } |
| 500 | |
| 501 | $newId = $idMap[(int)$row['id']]; |
| 502 | $oldParent = isset($row['parent']) ? (int)$row['parent'] : 0; |
| 503 | $newParent = $oldParent === 0 ? 0 : ($idMap[$oldParent] ?? 0); |
| 504 | $this->updateById('analytics_panorama', $newId, ['parent' => $newParent]); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * @param array<int,int> $reportMap |
no test coverage detected