summaryrefslogtreecommitdiffstats
path: root/Http/HttpUtils.php
diff options
context:
space:
mode:
Diffstat (limited to 'Http/HttpUtils.php')
-rw-r--r--Http/HttpUtils.php13
1 files changed, 4 insertions, 9 deletions
diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php
index ce03d1d..28373a7 100644
--- a/Http/HttpUtils.php
+++ b/Http/HttpUtils.php
@@ -35,7 +35,7 @@ class HttpUtils
* Constructor.
*
* @param UrlGeneratorInterface $urlGenerator A UrlGeneratorInterface instance
- * @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher
+ * @param UrlMatcherInterface|RequestMatcherInterface $urlMatcher The Url or Request matcher
*/
public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatcher = null)
{
@@ -71,8 +71,8 @@ class HttpUtils
public function createRequest(Request $request, $path)
{
$newRequest = call_user_func(array(get_class($request), 'create'), $this->generateUri($request, $path), 'get', array(), $request->cookies->all(), array(), $request->server->all());
- if ($session = $request->getSession()) {
- $newRequest->setSession($session);
+ if ($request->hasSession()) {
+ $newRequest->setSession($request->getSession());
}
if ($request->attributes->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
@@ -136,16 +136,11 @@ class HttpUtils
return $request->getUriForPath($path);
}
- return $this->generateUrl($path, $request->attributes->all(), true);
- }
-
- 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.');
}
- $url = $this->urlGenerator->generate($route, $attributes, $absolute);
+ $url = $this->urlGenerator->generate($path, $attributes, UrlGeneratorInterface::ABSOLUTE_URL);
// unnecessary query string parameters must be removed from url
// (ie. query parameters that are presents in $attributes)