Example #1
0
 /**
  *
  */
 protected static function _preLoad()
 {
     if (!self::$_preLoaded) {
         $topLevelPages = Page::getChildPages(0);
         self::_loadSubPaths($topLevelPages);
         $loadedIds = [];
         foreach (self::$_preLoaded as $pageId => $pagePathData) {
             if ($pagePathData->groupContainers) {
                 uasort($pagePathData->groupContainers, function ($a, $b) {
                     if ($a['canonical']) {
                         return -1;
                     }
                     if ($b['canonical']) {
                         return 1;
                     }
                     if ($a['priority'] == $b['priority']) {
                         if ($a['url'] == $b['url']) {
                             return 0;
                         }
                         return $a['url'] < $b['url'] ? -1 : 1;
                     }
                     return $a['priority'] > $b['priority'] ? -1 : 1;
                 });
                 reset($pagePathData->groupContainers);
                 $groupPath = current($pagePathData->groupContainers);
                 if ($groupPath['canonical'] || $groupPath['priority'] > 100 || is_null($pagePathData->fullUrl)) {
                     $pagePathData->fullName = $groupPath['name'] . $pagePathData->separator . $pagePathData->name;
                     $pagePathData->fullUrl = rtrim($groupPath['url'], '/') . '/' . $pagePathData->url;
                 }
             }
             $loadedIds[] = $pageId;
         }
         foreach (Page::preloadArray() as $pageId => $page) {
             if (!in_array($pageId, $loadedIds)) {
                 self::_getById($pageId);
             }
         }
     }
 }