Bluz\Router\Router::__construct PHP Метод

__construct() публичный Метод

Constructor of Router
public __construct ( )
    public function __construct()
    {
        $this->module = $this->getDefaultModule();
        $this->controller = $this->getDefaultController();
        $routers = Cache::get('router:routers');
        $reverse = Cache::get('router:reverse');
        if (!$routers || !$reverse) {
            $routers = [];
            $reverse = [];
            $path = Application::getInstance()->getPath() . '/modules/*/controllers/*.php';
            foreach (new \GlobIterator($path) as $file) {
                /* @var \SplFileInfo $file */
                $module = $file->getPathInfo()->getPathInfo()->getBasename();
                $controller = $file->getBasename('.php');
                $controllerInstance = new Controller($module, $controller);
                $reflection = $controllerInstance->getReflection();
                if ($routes = $reflection->getRoute()) {
                    foreach ($routes as $route => $pattern) {
                        if (!isset($reverse[$module])) {
                            $reverse[$module] = [];
                        }
                        $reverse[$module][$controller] = ['route' => $route, 'params' => $reflection->getParams()];
                        $rule = [$route => ['pattern' => $pattern, 'module' => $module, 'controller' => $controller, 'params' => $reflection->getParams()]];
                        // static routers should be first
                        if (strpos($route, '$')) {
                            $routers = array_merge($routers, $rule);
                        } else {
                            $routers = array_merge($rule, $routers);
                        }
                    }
                }
            }
            Cache::set('router:routers', $routers);
            Cache::set('router:reverse', $reverse);
        }
        $this->routers = $routers;
        $this->reverse = $reverse;
    }