Skip to content

Commit

Permalink
#372 - Optional attribute path on router:fromPath to replace current …
Browse files Browse the repository at this point in the history
…virtual url.
  • Loading branch information
maraf committed Oct 7, 2021
1 parent 3549c9d commit 89fada5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/app/scripts/php/libs/Router.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ private function isPathMatched($currentPath, $path) {
return strcasecmp($currentPath, $parsed) == 0;
}

public function fromPath($template) {
$virtualUrl = parent::web()->getVirtualUrl();
public function fromPath($template, $path = "x-invalid.path-x") {
if ($path != "x-invalid.path-x") {
$virtualUrl = trim($path, "/");
} else {
$virtualUrl = parent::web()->getVirtualUrl();
}
$this->virtualUrlParts = StringUtils::explode($virtualUrl, '/');
$this->virtualUrlPartsIndex = 0;
$this->canMatch = true;
Expand Down
10 changes: 9 additions & 1 deletion src/app/scripts/php/libs/Router.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
<name>fromPath</name>
<function>fromPath</function>
<lookless />
<attribute>
<name>path</name>
<type>string</type>
<default>x-invalid.path-x</default>
<comment>URL, která se má vyhodnotit.</comment>
</attribute>
<comment>
Router...
Router založený na path části URL.
Standartně router pracuje s aktuální path.
Pomocí atributu "path" je možné přesvědčit router, že má použít tuto místo aktuální.
</comment>
</fulltag>
<fulltag>
Expand Down

0 comments on commit 89fada5

Please sign in to comment.