You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
834 B
PHTML
32 lines
834 B
PHTML
7 years ago
|
<?php
|
||
|
|
||
6 years ago
|
namespace Engelsystem\Http;
|
||
7 years ago
|
|
||
7 years ago
|
/**
|
||
|
* Provides urls when webserver rewriting is disabled.
|
||
7 years ago
|
*
|
||
7 years ago
|
* The urls have the form <app url>/index.php?p=<path>&<parameters>
|
||
|
*/
|
||
7 years ago
|
class LegacyUrlGenerator extends UrlGenerator
|
||
|
{
|
||
|
/**
|
||
|
* @param string $path
|
||
|
* @param array $parameters
|
||
7 years ago
|
* @return string urls in the form <app url>/index.php?p=<path>&<parameters>
|
||
7 years ago
|
*/
|
||
6 years ago
|
public function to($path, $parameters = [])
|
||
7 years ago
|
{
|
||
|
$page = ltrim($path, '/');
|
||
|
if (!empty($page)) {
|
||
|
$page = str_replace('-', '_', $page);
|
||
|
$parameters = array_merge(['p' => $page], $parameters);
|
||
|
}
|
||
|
|
||
6 years ago
|
$uri = parent::to('index.php', $parameters);
|
||
7 years ago
|
$uri = preg_replace('~(/index\.php)+~', '/index.php', $uri);
|
||
7 years ago
|
$uri = preg_replace('~(/index\.php)$~', '/', $uri);
|
||
7 years ago
|
|
||
|
return $uri;
|
||
|
}
|
||
|
}
|