/** * Finds the UrlRewrite model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return \core\rewrite\models\UrlRewrite the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { /** @var \core\rewrite\models\UrlRewrite $modelClass */ $modelClass = Kiwi::getUrlRewriteClass(); if (($model = $modelClass::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function parseRequest($manager, $request) { $pathInfo = $request->getPathInfo(); $suffix = (string) ($this->suffix === null ? $manager->suffix : $this->suffix); if ($suffix !== '' && $pathInfo !== '') { $n = strlen($suffix); if (substr_compare($pathInfo, $suffix, -$n, $n) === 0) { $pathInfo = substr($pathInfo, 0, -$n); if ($pathInfo === '') { return false; } } else { return false; } } /** @var \core\rewrite\models\UrlRewrite $urlRewriteClass */ $urlRewriteClass = Kiwi::getUrlRewriteClass(); $urlRewrite = $urlRewriteClass::findOne(['request_path' => $pathInfo]); if ($urlRewrite) { return [$urlRewrite->route, $urlRewrite->getParamsArray($urlRewrite->params)]; } return false; // this rule does not apply }