diff options
author | msquare <msquare@notrademark.de> | 2017-09-11 17:52:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-11 17:52:55 +0200 |
commit | 359160613027a480620e22deef19ff883eaaeb21 (patch) | |
tree | 310600aaa23404f0cd7d3e198bacdbc93645da32 /src/Routing | |
parent | 581b81f1b25dc6b6f0a3b34810c293738fd40217 (diff) | |
parent | 0a20883aa862779b48fd2a297456c2db04cffb95 (diff) |
Merge pull request #344 from MyIgel/master
Prepared routing, added symfony http Closes #336 and closes #337
Diffstat (limited to 'src/Routing')
-rw-r--r-- | src/Routing/UrlGenerator.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Routing/UrlGenerator.php b/src/Routing/UrlGenerator.php new file mode 100644 index 00000000..8dc464c6 --- /dev/null +++ b/src/Routing/UrlGenerator.php @@ -0,0 +1,27 @@ +<?php + +namespace Engelsystem\Routing; + +use Engelsystem\Http\Request; + +class UrlGenerator +{ + /** + * @param string $path + * @param array $parameters + * @return string + */ + public static function to($path, $parameters = []) + { + $path = '/' . ltrim($path, '/'); + $request = Request::getInstance(); + $uri = $request->getUriForPath($path); + + if (!empty($parameters) && is_array($parameters)) { + $parameters = http_build_query($parameters); + $uri .= '?' . $parameters; + } + + return $uri; + } +} |