[Routing] added hostname matching support to YamlFileLoader
This commit is contained in:
parent
85d11af880
commit
cab450c94e
@ -27,7 +27,7 @@ use Symfony\Component\Config\Loader\FileLoader;
|
|||||||
class YamlFileLoader extends FileLoader
|
class YamlFileLoader extends FileLoader
|
||||||
{
|
{
|
||||||
private static $availableKeys = array(
|
private static $availableKeys = array(
|
||||||
'type', 'resource', 'prefix', 'pattern', 'options', 'defaults', 'requirements'
|
'type', 'resource', 'prefix', 'pattern', 'options', 'defaults', 'requirements', 'hostname_pattern',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,9 +70,10 @@ class YamlFileLoader extends FileLoader
|
|||||||
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
||||||
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
||||||
$options = isset($config['options']) ? $config['options'] : array();
|
$options = isset($config['options']) ? $config['options'] : array();
|
||||||
|
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null;
|
||||||
|
|
||||||
$this->setCurrentDir(dirname($path));
|
$this->setCurrentDir(dirname($path));
|
||||||
$collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix, $defaults, $requirements, $options);
|
$collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix, $defaults, $requirements, $options, $hostnamePattern);
|
||||||
} else {
|
} else {
|
||||||
$this->parseRoute($collection, $name, $config, $path);
|
$this->parseRoute($collection, $name, $config, $path);
|
||||||
}
|
}
|
||||||
@ -106,12 +107,13 @@ class YamlFileLoader extends FileLoader
|
|||||||
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
|
||||||
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
|
||||||
$options = isset($config['options']) ? $config['options'] : array();
|
$options = isset($config['options']) ? $config['options'] : array();
|
||||||
|
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null;
|
||||||
|
|
||||||
if (!isset($config['pattern'])) {
|
if (!isset($config['pattern'])) {
|
||||||
throw new \InvalidArgumentException(sprintf('You must define a "pattern" for the "%s" route.', $name));
|
throw new \InvalidArgumentException(sprintf('You must define a "pattern" for the "%s" route.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
$route = new Route($config['pattern'], $defaults, $requirements, $options);
|
$route = new Route($config['pattern'], $defaults, $requirements, $options, $hostnamePattern);
|
||||||
|
|
||||||
$collection->add($name, $route);
|
$collection->add($name, $route);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user