symfony/symfony — pull request #6430 by wiistriker (2012-12-20 02:29:29+00:00)
Title: [2.2][Routing] better hostname pattern group for PhpMatcherDumper

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

For example, we have such routes:

```
route1:
pattern: /bar
hostname_pattern: example.com

route2:
pattern: /foo

route3:
pattern: /foo/bar
hostname_pattern: example.com
```

in `cache//appUrlMatcher.php` we got (pseudo language):

```
$hostname = $this->context->getHost();

if ($hostname match "example.com") {
if ($pathinfo == '/bar') {
...
}
}

if ($pathinfo == '/foo2') {
...
}

if ($hostname match "example.com") {
if ($pathinfo == '/foo/bar') {
...
}
}
```

We have two matches against same hostname_pattern, so this PR group routes in this way:

```
$hostname = $this->context->getHost();

if ($hostname match "example.com") {
if ($pathinfo == '/bar') {
...
}

if ($pathinfo == '/foo/bar') {
...
}
}

if ($pathinfo == '/foo2') {
...
}
```