MCPcopy Create free account
hub / github.com/Rello/analytics / importPanoramas

Method importPanoramas

lib/UserMigration/AnalyticsMigrator.php:475–506  ·  view source on GitHub ↗

* @param list > $rows * @param array $reportMap * @throws Exception */

(string $uid, array $rows, array $reportMap)

Source from the content-addressed store, hash-verified

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

Callers 1

importMethod · 0.95

Calls 3

remapPanoramaPagesMethod · 0.95
insertAndReturnIdMethod · 0.95
updateByIdMethod · 0.95

Tested by

no test coverage detected