private function processDefaultRequestUri($uri, $postData) { $uriParts = explode('/', trim($uri, ' ')); if (count($uriParts) < 3) { throw new \Exception('No valid route found', 404); } $area = ucfirst($uriParts[0]); $controller = ucfirst($uriParts[1]); $action = $uriParts[2]; $params = array_slice($uriParts, 3); $fullControllerName = DirectoryHelper::getControllerPath($area, $controller); if (!isset($this->getAppStructure()[$area][$fullControllerName][$action])) { throw new \Exception('No valid route found', 404); } $this->setAreaName($area); $this->setControllerName(ucfirst($controller)); $this->setActionName($action); $this->setRequestParams($params); if (!$this->validatePostData($postData)) { throw new \Exception('Invalid data supplied'); } return new RequestUriResult($this->getAreaName(), $this->getControllerName(), $this->getActionName(), $this->getRequestParams()); }
private function initController(RequestUriResult $requestUriResult, View $view) { if (!$requestUriResult) { throw new \Exception('Url parse error'); } $fullControllerName = DirectoryHelper::getControllerPath($requestUriResult->getAreaName(), $requestUriResult->getControllerName()); $controller = new $fullControllerName($requestUriResult, $view); $this->setController($controller); }