summaryrefslogtreecommitdiff
path: root/src/Routing/LegacyUrlGenerator.php
blob: f17bdf88b67bb37884062d07d82519bdac7a08c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
    }
}