/**
  * Returns or constructs the route object to use for this module
  * @return IDateLinkRouter
  */
 public static function instance()
 {
     if (empty(self::$_instance)) {
         self::$_instance = DateLinkRouter::create();
     }
     return self::$_instance;
 }
 /**
  * Instructs the module to refresh the routing XML cache file
  * This may not be called during manifest initialisation (_config.php) as database access is not available
  */
 public function RefreshCache()
 {
     // Builds XML cache file using all available routes
     $document = new DOMDocument();
     $document->formatOutput = true;
     $routes = $document->createElement('routes');
     $document->appendChild($routes);
     // append all routes
     $holderClasses = DateLink::config()->holder_classes;
     foreach ($holderClasses as $className) {
         foreach (DataObject::get($className) as $holderPage) {
             $route = $document->createElement('route');
             $link = $document->createElement('link', $holderPage->RelativeLink());
             $route->appendChild($link);
             $id = $document->createElement('page_id', $holderPage->ID);
             $route->appendChild($id);
             // Run through children and pull out all distinct year fields
             // We must use years in our URLS to distinguish all routes from non-numeric routes such as
             // page actions. It's not necessary to consider months, as by then the route will be sufficiently
             // distinguished.
             $children = $holderPage->AllChildren();
             $yearList = $this->determineYears($children);
             $years = $document->createElement('years');
             foreach ($yearList as $yearNumber) {
                 $year = $document->createElement('year', $yearNumber);
                 $years->appendChild($year);
             }
             $route->appendChild($years);
             $routes->appendChild($route);
         }
     }
     // Ensure output directory exists
     $outputPath = $this->getCacheFilePath();
     Filesystem::makeFolder(dirname($outputPath));
     $document->save($outputPath);
 }
 public function requireDefaultRecords()
 {
     // Prevent this function being executed excessively each request
     if (self::$_cache_refreshed) {
         return;
     }
     self::$_cache_refreshed = true;
     // Hook into dev/build task here to refresh the xml routing cache
     DateLink::refresh_cache();
 }
<?php

// Forces registration of all pre-calculated routes
DateLink::register_routes();