[Routing] added hostname matching support to AnnotationClassLoader
This commit is contained in:
parent
cab450c94e
commit
7a15e006e6
@ -25,6 +25,7 @@ class Route
|
||||
private $requirements;
|
||||
private $options;
|
||||
private $defaults;
|
||||
private $hostnamePattern;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -61,6 +62,16 @@ class Route
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
public function setHostnamePattern($pattern)
|
||||
{
|
||||
$this->hostnamePattern = $pattern;
|
||||
}
|
||||
|
||||
public function getHostnamePattern()
|
||||
{
|
||||
return $this->hostnamePattern;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
@ -97,10 +97,11 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
}
|
||||
|
||||
$globals = array(
|
||||
'pattern' => '',
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
'pattern' => '',
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
'hostname_pattern' => null,
|
||||
);
|
||||
|
||||
$class = new \ReflectionClass($class);
|
||||
@ -124,6 +125,10 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
if (null !== $annot->getDefaults()) {
|
||||
$globals['defaults'] = $annot->getDefaults();
|
||||
}
|
||||
|
||||
if (null !== $annot->getHostnamePattern()) {
|
||||
$globals['hostname_pattern'] = $annot->getHostnamePattern();
|
||||
}
|
||||
}
|
||||
|
||||
$collection = new RouteCollection();
|
||||
@ -157,7 +162,12 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||
$requirements = array_merge($globals['requirements'], $annot->getRequirements());
|
||||
$options = array_merge($globals['options'], $annot->getOptions());
|
||||
|
||||
$route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options);
|
||||
$hostnamePattern = $annot->getHostnamePattern();
|
||||
if (null === $hostnamePattern) {
|
||||
$hostnamePattern = $globals['hostname_pattern'];
|
||||
}
|
||||
|
||||
$route = new Route($globals['pattern'].$annot->getPattern(), $defaults, $requirements, $options, $hostnamePattern);
|
||||
|
||||
$this->configureRoute($route, $class, $method, $annot);
|
||||
|
||||
|
Reference in New Issue
Block a user