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