private function buildMaps() { $list = $this->loadStubPages(); foreach ($list as &$page) { //restructure any child pages in the index, to the top level if (array_key_exists('childPages', $page)) { foreach ($page['childPages'] as $childPage) { $childPage['_parentPageCode'] = $page['code']; array_push($list, $childPage); } unset($page['childPages']); } //default some basic properties $page = array_replace(['code' => null, 'title' => null, 'slug' => null, 'module' => null, '_parentPageCode' => null], $page); } unset($page); //generate the lookup and tree $lookup = StructUtils::delegate($list, 'code'); $tree = StructUtils::tree($list, 'code', '_parentPageCode', 'childPages', 'parentPage'); foreach ($lookup as &$page) { unset($page['_parentPageCode']); //generate url $url = ''; $tempPage = $page; do { if ($tempPage['slug']) { $url = $tempPage['slug'] . '/' . $url; } } while (($tempPage = $tempPage['parentPage']) != null); $page['url'] = '/' . $url; //normalize item $page = $this->normalizeStubPage($page); } unset($page); $this->pagesLookup =& $lookup; $this->pagesTree =& $tree; }