$plan * @return array */ public static function upgrade(array $plan): array { if (($plan['version'] ?? null) !== 1) { return $plan; } $header = null; $footer = null; $body = []; foreach ($plan['sections'] ?? [] as $section) { $type = $section['type'] ?? null; $shared = ['variant' => $section['variant'] ?? null, 'content' => $section['content'] ?? []]; if ($type === 'header' && $header === null) { $header = $shared; } elseif ($type === 'footer') { $footer = $shared; } elseif ($type !== 'header') { $body[] = $section; } } return [ 'version' => 2, 'theme' => $plan['theme'] ?? [], 'header' => $header ?? ['variant' => 'simple', 'content' => ['logoText' => 'Store', 'links' => []]], 'footer' => $footer ?? ['variant' => 'simple', 'content' => ['text' => '', 'links' => []]], 'pages' => [ ['id' => PlanSchema::HOME_PAGE, 'title' => 'Home', 'sections' => $body], ], ]; } }