bug #19088 [Routing] treat fragment after resolving query string params (xabbuh)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[Routing] treat fragment after resolving query string params

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

The implementation from #12979 led to a conflict with #18280 which was merged in the meantime.

Commits
-------

7475aa8 treat fragment after resolving query string params
This commit is contained in:
Fabien Potencier 2016-06-17 16:25:43 +02:00
commit 22f7ed7d9e
1 changed files with 4 additions and 7 deletions

View File

@ -257,18 +257,15 @@ class UrlGenerator implements UrlGeneratorInterface, ConfigurableRequirementsInt
$url = $schemeAuthority.$this->context->getBaseUrl().$url;
}
// extract unused parameters
$extra = array_diff_key($parameters, $variables, $defaults);
// extract fragment
$fragment = isset($extra['_fragment']) ? $extra['_fragment'] : '';
unset($extra['_fragment']);
// add a query string if needed
$extra = array_udiff_assoc(array_diff_key($parameters, $variables), $defaults, function ($a, $b) {
return $a == $b ? 0 : 1;
});
// extract fragment
$fragment = isset($extra['_fragment']) ? $extra['_fragment'] : '';
unset($extra['_fragment']);
if ($extra && $query = http_build_query($extra, '', '&')) {
// "/" and "?" can be left decoded for better user experience, see
// http://tools.ietf.org/html/rfc3986#section-3.4