diff options
author | Jean-François Simon <contact@jfsimon.fr> | 2013-03-11 06:59:49 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2013-03-13 18:34:15 +0100 |
commit | 339f14cab6ffc0a4285f480a7487b32e3d4c20c1 (patch) | |
tree | 9dc4d7414f1a9cd7e8f5f216e6e6158889431075 /Http/HttpUtils.php | |
parent | 32b46da27a08ebf51e2d8ea1aa82e39c56c0bcfe (diff) | |
download | symfony-security-339f14cab6ffc0a4285f480a7487b32e3d4c20c1.zip symfony-security-339f14cab6ffc0a4285f480a7487b32e3d4c20c1.tar.gz symfony-security-339f14cab6ffc0a4285f480a7487b32e3d4c20c1.tar.bz2 |
[Security] use current request attributes to generate redirect url?
Diffstat (limited to 'Http/HttpUtils.php')
-rw-r--r-- | Http/HttpUtils.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php index 81893ff..761aa5a 100644 --- a/Http/HttpUtils.php +++ b/Http/HttpUtils.php @@ -136,15 +136,25 @@ class HttpUtils return $request->getUriForPath($path); } - return $this->generateUrl($path, true); + return $this->generateUrl($path, $request->attributes->all(), true); } - private function generateUrl($route, $absolute = false) + private function generateUrl($route, array $attributes = array(), $absolute = false) { if (null === $this->urlGenerator) { throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.'); } - return $this->urlGenerator->generate($route, array(), $absolute); + $url = $this->urlGenerator->generate($route, $attributes, $absolute); + + // unnecessary query string parameters must be removed from url + // (ie. query parameters that are presents in $attributes) + // fortunately, they all are, so we have to remove entire query string + $position = strpos($url, '?'); + if (false !== $position) { + $url = substr($url, 0, $position); + } + + return $url; } } |