@@ -98,10 +98,11 @@ public function load($class, $type = null)
98
98
}
99
99
100
100
$ globals = array (
101
- 'pattern ' => '' ,
102
- 'requirements ' => array (),
103
- 'options ' => array (),
104
- 'defaults ' => array (),
101
+ 'pattern ' => '' ,
102
+ 'requirements ' => array (),
103
+ 'options ' => array (),
104
+ 'defaults ' => array (),
105
+ 'hostname_pattern ' => null ,
105
106
);
106
107
107
108
$ class = new \ReflectionClass ($ class );
@@ -125,6 +126,10 @@ public function load($class, $type = null)
125
126
if (null !== $ annot ->getDefaults ()) {
126
127
$ globals ['defaults ' ] = $ annot ->getDefaults ();
127
128
}
129
+
130
+ if (null !== $ annot ->getHostnamePattern ()) {
131
+ $ globals ['hostname_pattern ' ] = $ annot ->getHostnamePattern ();
132
+ }
128
133
}
129
134
130
135
$ collection = new RouteCollection ();
@@ -153,7 +158,12 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
153
158
$ requirements = array_merge ($ globals ['requirements ' ], $ annot ->getRequirements ());
154
159
$ options = array_merge ($ globals ['options ' ], $ annot ->getOptions ());
155
160
156
- $ route = new Route ($ globals ['pattern ' ].$ annot ->getPattern (), $ defaults , $ requirements , $ options );
161
+ $ hostnamePattern = $ annot ->getHostnamePattern ();
162
+ if (null === $ hostnamePattern ) {
163
+ $ hostnamePattern = $ globals ['hostname_pattern ' ];
164
+ }
165
+
166
+ $ route = new Route ($ globals ['pattern ' ].$ annot ->getPattern (), $ defaults , $ requirements , $ options , $ hostnamePattern );
157
167
158
168
$ this ->configureRoute ($ route , $ class , $ method , $ annot );
159
169
0 commit comments