diff options
author | msquare <msquare@notrademark.de> | 2018-09-07 20:50:31 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2018-09-07 20:50:31 +0200 |
commit | 2d6bca1357faff28bc1f86a56b432cc463ff7574 (patch) | |
tree | ce18461d2e170ac28dd365342a1f125a8a31aa3a /src/Http/LegacyUrlGenerator.php | |
parent | b320fc779063ee80b8f0ba505cb323287ccccbf5 (diff) | |
parent | ce6d0fd13b54ac79a955b85d50860736a520d333 (diff) |
Merge branch 'MyIgel-routing'
Diffstat (limited to 'src/Http/LegacyUrlGenerator.php')
-rw-r--r-- | src/Http/LegacyUrlGenerator.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Http/LegacyUrlGenerator.php b/src/Http/LegacyUrlGenerator.php new file mode 100644 index 00000000..b9f8b7f1 --- /dev/null +++ b/src/Http/LegacyUrlGenerator.php @@ -0,0 +1,31 @@ +<?php + +namespace Engelsystem\Http; + +/** + * Provides urls when webserver rewriting is disabled. + * + * The urls have the form <app url>/index.php?p=<path>&<parameters> + */ +class LegacyUrlGenerator extends UrlGenerator +{ + /** + * @param string $path + * @param array $parameters + * @return string urls in the form <app url>/index.php?p=<path>&<parameters> + */ + public function to($path, $parameters = []) + { + $page = ltrim($path, '/'); + if (!empty($page)) { + $page = str_replace('-', '_', $page); + $parameters = array_merge(['p' => $page], $parameters); + } + + $uri = parent::to('index.php', $parameters); + $uri = preg_replace('~(/index\.php)+~', '/index.php', $uri); + $uri = preg_replace('~(/index\.php)$~', '/', $uri); + + return $uri; + } +} |