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);
}