diff options
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; + } +} |