private function processDefaultRequestUri($uri, $postData) { $uriParts = explode('/', trim($uri, ' ')); if (count($uriParts) < 3) { http_response_code(404); die('No action found'); } $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])) { http_response_code(404); die('No action found'); } $this->setAreaName($area); $this->setControllerName(ucfirst($controller)); $this->setActionName($action); $this->setRequestParams($params); if (!$this->validatePostData($postData)) { http_response_code(400); die('Invalid data supplied'); } return new RequestUriResult($this->getAreaName(), $this->getControllerName(), $this->getActionName(), $this->getRequestParams()); }
private function initController(RequestUriResult $requestUriResult) { if (!$requestUriResult) { throw new \Exception('Url parse error'); } $fullControllerName = DirectoryHelper::getControllerPath($requestUriResult->getAreaName(), $requestUriResult->getControllerName()); $controller = new $fullControllerName($requestUriResult); $this->setController($controller); }