public function loadRoutesCache(): bool
    {
        if (!$this->isCacheEnable()) {
            return false;
        }

        $file = $this->cacheFile;
        if (!$file || !\file_exists($file)) {
            return false;
        }

        // load routes
        $map = require $file;
        $this->routeCounter = 0;
        $staticRoutes = $regularRoutes = $vagueRoutes = [];

        foreach ($map['staticRoutes'] as $key => $info) {
            $this->routeCounter++;
            $staticRoutes[$key] = Route::createFromArray($info);
        }

        foreach ($map['regularRoutes'] as $key => $routes) {
            foreach ($routes as $info) {
                $this->routeCounter++;
                $regularRoutes[$key][] = Route::createFromArray($info);
            }
        }

        foreach ($map['vagueRoutes'] as $key => $routes) {
            foreach ($routes as $info) {
                $this->routeCounter++;
                $vagueRoutes[$key][] = Route::createFromArray($info);
            }
        }

        $this->staticRoutes = $staticRoutes;
        $this->regularRoutes = $regularRoutes;
        $this->vagueRoutes = $vagueRoutes;
        $this->cacheLoaded = true;

        return true;
    }
public function loadRoutesCache(): bool
    {
        if (!$this->isCacheEnable()) {
            return false;
        }

        $file = $this->cacheFile;
        if (!$file || !\file_exists($file)) {
            return false;
        }

        // load routes
        $map = require $file;
        $this->routeCounter = 0;
        $staticRoutes = $regularRoutes = $vagueRoutes = [];

        foreach ($map['staticRoutes'] as $key => $info) {
            $this->routeCounter++;
            $staticRoutes[$key] = Route::createFromArray($info);
        }

        foreach ($map['regularRoutes'] as $key => $routes) {
            foreach ($routes as $info) {
                $this->routeCounter++;
                $regularRoutes[$key][] = Route::createFromArray($info);
            }
        }

        foreach ($map['vagueRoutes'] as $key => $routes) {
            foreach ($routes as $info) {
                $this->routeCounter++;
                $vagueRoutes[$key][] = Route::createFromArray($info);
            }
        }

        $this->staticRoutes = $staticRoutes;
        $this->regularRoutes = $regularRoutes;
        $this->vagueRoutes = $vagueRoutes;
        $this->cacheLoaded = true;

        return true;
    }
public function loadRoutesCache ( ) : bool { if ( ! $ this -> isCacheEnable ( ) ) { return false ; } $ file = $ this -> cacheFile ; if ( ! $ file || ! \ file_exists ( $ file ) ) { return false ; } // load routes $ map = require $ file ; $ this -> routeCounter = 0 ; $ staticRoutes = $ regularRoutes = $ vagueRoutes = [ ] ; foreach ( $ map [ 'staticRoutes' ] as $ key => $ info ) { $ this -> routeCounter ++ ; $ staticRoutes [ $ key ] = Route :: createFromArray ( $ info ) ; } foreach ( $ map [ 'regularRoutes' ] as $ key => $ routes ) { foreach ( $ routes as $ info ) { $ this -> routeCounter ++ ; $ regularRoutes [ $ key ] [ ] = Route :: createFromArray ( $ info ) ; } } foreach ( $ map [ 'vagueRoutes' ] as $ key => $ routes ) { foreach ( $ routes as $ info ) { $ this -> routeCounter ++ ; $ vagueRoutes [ $ key ] [ ] = Route :: createFromArray ( $ info ) ; } } $ this -> staticRoutes = $ staticRoutes ; $ this -> regularRoutes = $ regularRoutes ; $ this -> vagueRoutes = $ vagueRoutes ; $ this -> cacheLoaded = true ; return true ; }
load route caches from the cache file
@return bool
load route caches from the cache file