Gear::controllerHandler PHP Method

controllerHandler() private method

The steps is: - Does alias controller are defined in main config? - If not, is sub-controller exists? - If not, module with this name exists? - If all fault, then throw 404.
private controllerHandler ( )
    private function controllerHandler()
    {
        $controllerNamespace = 'Controllers\\' . $this->firstUriPath;
        if (!file_exists($classFile = APP . 'Controllers/' . $this->firstUriPath . '.php')) {
            $this->subControllerHandler();
            return;
        }
        $method = $this->uriObj->getMethod();
        if (!($request = $this->uriObj->getRequests())) {
            $request = array();
        }
        if (!class_exists($controllerNamespace)) {
            throw new Resources\RunException('Class ' . $controllerNamespace . '  not found in ' . $classFile);
        }
        $instance = new $controllerNamespace();
        if (!method_exists($instance, $method)) {
            $request = array_slice($this->uriObj->path(), 1);
            $method = $this->config['main']['alias']['method'];
            if (!method_exists($instance, $method)) {
                throw new Resources\HttpException('Method ' . $this->uriObj->getMethod() . ' does not exists in controller ' . $this->firstUriPath);
            }
        }
        $this->run($instance, $method, $request);
    }