/** * CLI commands run from app/console.php * * Maps HTTP request to a Request object. * @return Nette\Application\Request|NULL */ public function match(Nette\Http\IRequest $httpRequest) { $this->loadLocales(); $urlPath = new Services\UrlPath($httpRequest); $urlPath->setPredefinedLocales($this->locales); /** @var Url $urlEntity */ $urlEntity = $this->loadUrlEntity($urlPath->getPath(true)); if ($urlEntity === null) { // no route found $this->onUrlNotFound($urlPath); return null; } if ($urlEntity->getActualUrlToRedirect() === null) { $presenter = $urlEntity->getPresenter(); $internal_id = $urlEntity->getInternalId(); $action = $urlEntity->getAction(); } else { $presenter = $urlEntity->getActualUrlToRedirect()->getPresenter(); $internal_id = $urlEntity->getActualUrlToRedirect()->getInternalId(); $action = $urlEntity->getActualUrlToRedirect()->getAction(); } $params = $httpRequest->getQuery(); $params['action'] = $action; $params['locale'] = $urlPath->getLocale(); $this->urlParametersConverter->in($urlEntity, $params); // todo if ($internal_id !== null) { $params['internal_id'] = $internal_id; } return new Nette\Application\Request($presenter, $httpRequest->getMethod(), $params, $httpRequest->getPost(), $httpRequest->getFiles()); }
public function onUrlNotFound(UrlPath $urlPath) { $this->appEventLogger->saveLog(sprintf('<b>[404]</b> Url "%s" <b>NOT found</b>', $urlPath->getPath()), '404'); }