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

Method importPanoramas

lib/UserMigration/AnalyticsMigrator.php:345–376  ·  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

343 * @throws Exception
344 */
345 private function importPanoramas(string $uid, array $rows, array $reportMap): void {
346 $idMap = [];
347
348 foreach ($rows as $row) {
349 if (!isset($row['id'])) {
350 continue;
351 }
352
353 $oldId = (int)$row['id'];
354 $pages = $this->remapPanoramaPages((string)($row['pages'] ?? '[]'), $reportMap);
355
356 $newId = $this->insertAndReturnId('analytics_panorama', [
357 'user_id' => $uid,
358 'name' => $row['name'] ?? '',
359 'type' => isset($row['type']) ? (int)$row['type'] : 0,
360 'parent' => 0,
361 'pages' => $pages,
362 ]);
363 $idMap[$oldId] = $newId;
364 }
365
366 foreach ($rows as $row) {
367 if (!isset($row['id']) || !isset($idMap[(int)$row['id']])) {
368 continue;
369 }
370
371 $newId = $idMap[(int)$row['id']];
372 $oldParent = isset($row['parent']) ? (int)$row['parent'] : 0;
373 $newParent = $oldParent === 0 ? 0 : ($idMap[$oldParent] ?? 0);
374 $this->updateById('analytics_panorama', $newId, ['parent' => $newParent]);
375 }
376 }
377
378 /**
379 * @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