Skip to content

Commit

Permalink
[Routing] added hostname matching support to YamlFileLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed Nov 12, 2012
1 parent 85d11af commit cab450c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Symfony/Component/Routing/Loader/YamlFileLoader.php
Expand Up @@ -27,7 +27,7 @@
class YamlFileLoader extends FileLoader
{
private static $availableKeys = array(
'type', 'resource', 'prefix', 'pattern', 'options', 'defaults', 'requirements'
'type', 'resource', 'prefix', 'pattern', 'options', 'defaults', 'requirements', 'hostname_pattern',
);

/**
Expand Down Expand Up @@ -70,9 +70,10 @@ public function load($file, $type = null)
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
$options = isset($config['options']) ? $config['options'] : array();
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null;

$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 {
$this->parseRoute($collection, $name, $config, $path);
}
Expand Down Expand Up @@ -106,12 +107,13 @@ protected function parseRoute(RouteCollection $collection, $name, $config, $file
$defaults = isset($config['defaults']) ? $config['defaults'] : array();
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
$options = isset($config['options']) ? $config['options'] : array();
$hostnamePattern = isset($config['hostname_pattern']) ? $config['hostname_pattern'] : null;

if (!isset($config['pattern'])) {
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);
}
Expand Down

0 comments on commit cab450c

Please sign in to comment.