symfony/symfony — pull request #10254 by notrix (2014-02-12 22:17:01+00:00)
Title:  [Routing] add support for optional placeholders in the host

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #7306
| License | MIT

New feature to support optional placeholders in host pattern. The main difference is that host pattern cannot be parsed same as path pattern.
In path optional placeholders are located in the end like
```
/example/{mandatory}/{optional1}/{optional2}
```
And hosts can have optional placeholders in the beginning like
```
{optional1}.{optional2}.{mandatory}.example.com
```
So I have split compilePattern() method in compilePathPattern() and compileHostPattern() that have different compiling flow.
The goal was to be able configure host like
```yaml
example:
path: /example
host: {subdomain}.example.com
defaults: { subdomain: "" }
```