RainLab\Pages\Classes\PageList::listPages PHP Method

listPages() public method

This method is used internally by the system.
public listPages ( boolean $skipCache = false ) : array
$skipCache boolean Indicates if objects should be reloaded from the disk bypassing the cache.
return array Returns an array of static pages.
    public function listPages($skipCache = false)
    {
        return Page::listInTheme($this->theme, $skipCache);
    }

Usage Example

Esempio n. 1
0
 /**
  * Loads the URL map - a list of page file names and corresponding URL patterns.
  * The URL map can is cached. The clearUrlMap() method resets the cache. By default
  * the map is updated every time when a page is saved in the back-end, or 
  * when the interval defined with the cms.urlCacheTtl expires.
  * @return boolean Returns true if the URL map was loaded from the cache. Otherwise returns false.
  */
 protected function loadUrlMap()
 {
     $key = $this->getCacheKey('static-page-url-map');
     $cacheable = Config::get('cms.enableRoutesCache');
     $cached = $cacheable ? Cache::get($key, false) : false;
     if (!$cached || ($unserialized = @unserialize($cached)) === false) {
         /*
          * The item doesn't exist in the cache, create the map
          */
         $pageList = new PageList($this->theme);
         $pages = $pageList->listPages();
         $map = ['urls' => [], 'files' => [], 'titles' => []];
         foreach ($pages as $page) {
             $url = $page->getViewBag()->property('url');
             if (!$url) {
                 continue;
             }
             $url = Str::lower(RouterHelper::normalizeUrl($url));
             $file = $page->getBaseFileName();
             $map['urls'][$url] = $file;
             $map['files'][$file] = $url;
             $map['titles'][$file] = $page->getViewBag()->property('title');
         }
         self::$urlMap = $map;
         if ($cacheable) {
             Cache::put($key, serialize($map), Config::get('cms.urlCacheTtl', 1));
         }
         return false;
     }
     self::$urlMap = $unserialized;
     return true;
 }