protected function initSite($siteId) { $websiteService = new WebsiteService('Website'); $missingId = 'SITE-20b2394c-b41c-490f-1111-70bb15968c52-SITE'; $websiteData = $websiteService->getById($missingId); $renderWebsite = new \Dual\Render\Website(); $renderWebsite->setArray($websiteData->toArray()); CurrentSite::setSite($renderWebsite); }
protected static function initCurrentSite() { // resolutions $res = self::$newRenderContext->getResolutions(); $resolutionJsonString = json_encode($res); // color scheme $colorInfoStorage = self::$newRenderContext->getColorInfoStorage(); $colorScheme = array(); foreach ($colorInfoStorage->getColorIds() as $cid) { $colorScheme[] = array('id' => $cid, 'value' => $colorInfoStorage->getColor($cid), 'name' => ''); } $colorSchemeJsonString = json_encode($colorScheme); // navigation $navigationInfoStorage = self::$newRenderContext->getNavigationInfoStorage(); $rootIds = $navigationInfoStorage->getRootChildrenIds(); $fillNav = function ($ids) use($navigationInfoStorage, &$fillNav) { $nav = array(); foreach ($ids as $id) { $item = array('id' => $id, 'children' => array()); $childrenIds = $navigationInfoStorage->getChildrenIds($id); if (!empty($childrenIds)) { $item['children'] = $fillNav($childrenIds); } $nav[] = $item; } return $nav; }; $navigation = json_encode($fillNav($rootIds)); $websiteArray = array('id' => self::$websiteId, 'name' => 'WEBSITE', 'description' => '', 'navigation' => $navigation, 'publish' => '', 'colorscheme' => $colorSchemeJsonString, 'resolutions' => $resolutionJsonString, 'version' => '', 'home' => '', 'creationmode' => '', 'ismarkedfordeletion' => false, 'lastupdate' => ''); $website = new \Dual\Render\Website(); $website->setArray($websiteArray); \Dual\Render\CurrentSite::setSite($website); }