Pagekit\Debug\DataCollector\RoutesDataCollector::collect PHP Method

collect() public method

public collect ( )
    public function collect()
    {
        $path = sprintf($this->cache . '/' . $this->file, sha1(filemtime((new \ReflectionClass($this->router->getGenerator()))->getFileName())));
        if (!file_exists($path)) {
            $routes = [];
            foreach ($this->router->getRouteCollection() as $name => $route) {
                $routes[] = ['name' => $name, 'path' => $route->getPath(), 'methods' => $route->getMethods(), 'controller' => is_string($ctrl = $route->getDefault('_controller')) ? $ctrl : 'Closure'];
            }
            file_put_contents($path, '<?php return ' . var_export($routes, true) . ';');
        } else {
            $routes = (require $path);
        }
        $route = $this->route;
        return compact('routes', 'route');
    }