diff options
author | msquare <msquare@notrademark.de> | 2018-08-06 12:30:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-06 12:30:30 +0200 |
commit | a3ce3ea23de2e38968ddc98baf330dfa1f544b1a (patch) | |
tree | 646a1dca1db5e801f70733ce6b30d8682241207f /src/Routing/LegacyUrlGenerator.php | |
parent | 9ca36bed3446cdd4060d7d6fa1025512d0922e0e (diff) | |
parent | 6962c2b790b5428699fe5897de840d41090fcd37 (diff) |
Merge pull request #443 from MyIgel/legacy-url-support
UrlGeneratorInterface and "Legacy URL" support
Diffstat (limited to 'src/Routing/LegacyUrlGenerator.php')
-rw-r--r-- | src/Routing/LegacyUrlGenerator.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Routing/LegacyUrlGenerator.php b/src/Routing/LegacyUrlGenerator.php new file mode 100644 index 00000000..f17bdf88 --- /dev/null +++ b/src/Routing/LegacyUrlGenerator.php @@ -0,0 +1,25 @@ +<?php + +namespace Engelsystem\Routing; + +class LegacyUrlGenerator extends UrlGenerator +{ + /** + * @param string $path + * @param array $parameters + * @return string + */ + 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); + + return $uri; + } +} |