2017-08-29 16:21:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Routing;
|
|
|
|
|
2018-03-31 05:19:49 +02:00
|
|
|
class UrlGenerator implements UrlGeneratorInterface
|
2017-08-29 16:21:25 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $path
|
|
|
|
* @param array $parameters
|
|
|
|
* @return string
|
|
|
|
*/
|
2017-09-20 01:09:11 +02:00
|
|
|
public function to($path, $parameters = [])
|
2017-08-29 16:21:25 +02:00
|
|
|
{
|
|
|
|
$path = '/' . ltrim($path, '/');
|
2017-08-31 17:30:54 +02:00
|
|
|
$request = app('request');
|
2017-08-29 16:21:25 +02:00
|
|
|
$uri = $request->getUriForPath($path);
|
|
|
|
|
|
|
|
if (!empty($parameters) && is_array($parameters)) {
|
|
|
|
$parameters = http_build_query($parameters);
|
|
|
|
$uri .= '?' . $parameters;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $uri;
|
|
|
|
}
|
|
|
|
}
|