Skip to content

Commit b47bb73

Browse files
committed
Using for routing decisions
1 parent a1b8fbc commit b47bb73

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/WebApp/Router.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,25 @@ public function getCanonicalPath($pagePath = NULL, $language = NULL) {
8282
}
8383
if (($pagePath == NULL) && ($language != NULL)) $pagePath = $this->request->pagePath;
8484
if ($pagePath != NULL) {
85-
if ($language == NULL) $language = $this->request->language;
86-
if (!$this->request->useLanguagePath || ($language == NULL)) $language = '';
87-
else $language = '/'.$language;
88-
89-
return $this->getAbsolutePath($language.$pagePath);
85+
return $this->computeCanonicalPath($pagePath, $language);
9086
}
9187
return $this->request->canonicalPath;
9288
}
9389

90+
/**
91+
* Computes the absolute canonical URI path for a page path from the app root.
92+
* @param string $pagePath - a page path
93+
* @param string $language - the language to be used
94+
* @return string the absolute, canonical path for the page with this language.
95+
*/
96+
protected function computeCanonicalPath($pagePath, $language) {
97+
if ($language == NULL) $language = $this->request->language;
98+
if (!$this->request->useLanguagePath || ($language == NULL)) $language = '';
99+
else $language = '/'.$language;
100+
101+
return $this->getAbsolutePath($language.$pagePath);
102+
}
103+
94104
public function getPagePath() {
95105
if (!isset($this->request->pagePath)) {
96106
$this->initPagePath();

src/WebApp/Service.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ protected function createPage() {
4040

4141
// Check the path info
4242
$canonical = $this->app->router->getCanonicalPath();
43-
if ($request->path != $canonical) {
43+
$requested = $request->originalPath;
44+
if ($requested != $canonical) {
4445
$params = $request->params;
4546
if ($params) $params = '?'.$params;
4647
header('Location: '.$canonical.$params);

0 commit comments

Comments
 (0)