Fluent::regenerate_routes PHP Method

regenerate_routes() public static method

Forces regeneration of all locale routes
public static regenerate_routes ( )
    public static function regenerate_routes()
    {
        $routes = array();
        // Explicit routes
        foreach (self::locales() as $locale) {
            $url = self::alias($locale);
            $routes[$url . '/$URLSegment!//$Action/$ID/$OtherID'] = array('Controller' => 'ModelAsController', self::config()->query_param => $locale);
            $routes[$url] = array('Controller' => 'FluentRootURLController', self::config()->query_param => $locale);
        }
        // If Google sitemap module is installed then replace default controller with custom controller
        if (class_exists('GoogleSitemapController')) {
            $routes['sitemap.xml'] = 'FluentSitemapController';
        }
        // Merge all other routes (maintain priority)
        foreach (Config::inst()->get('Director', 'rules') as $key => $route) {
            if (!isset($routes[$key])) {
                $routes[$key] = $route;
            }
        }
        // Home page route
        $routes[''] = array('Controller' => 'FluentRootURLController');
        // If we do not wish to detect the locale automatically, fix the home page route
        // to the default locale for this domain.
        if (!Fluent::config()->detect_locale) {
            $routes[''][self::config()->query_param] = static::default_locale(true);
        }
        // If default locale doesn't have prefix, replace default route with
        // the default locale for this domain
        if (static::disable_default_prefix()) {
            $routes['$URLSegment//$Action/$ID/$OtherID'] = array('Controller' => 'ModelAsController', self::config()->query_param => static::default_locale(true));
        }
        $singleton = singleton(__CLASS__);
        $singleton->extend('updateRegenerateRoutes', $routes);
        // Load into core routes
        Config::inst()->remove('Director', 'rules');
        Config::inst()->update('Director', 'rules', $routes);
        $singleton->extend('onAfterRegenerateRoutes');
    }