@@ -97,10 +97,11 @@ public function load($class, $type = null)
9797 }
9898
9999 $ 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 ,
104105 );
105106
106107 $ class = new \ReflectionClass ($ class );
@@ -124,6 +125,10 @@ public function load($class, $type = null)
124125 if (null !== $ annot ->getDefaults ()) {
125126 $ globals ['defaults ' ] = $ annot ->getDefaults ();
126127 }
128+
129+ if (null !== $ annot ->getHostnamePattern ()) {
130+ $ globals ['hostname_pattern ' ] = $ annot ->getHostnamePattern ();
131+ }
127132 }
128133
129134 $ collection = new RouteCollection ();
@@ -157,7 +162,12 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
157162 $ requirements = array_merge ($ globals ['requirements ' ], $ annot ->getRequirements ());
158163 $ options = array_merge ($ globals ['options ' ], $ annot ->getOptions ());
159164
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 );
161171
162172 $ this ->configureRoute ($ route , $ class , $ method , $ annot );
163173
0 commit comments