Parses a route and adds it to the RouteCollection.
RouteCollection $collection A RouteCollection instance:
string $name Route name:
array $config Route definition:
string $file A Yaml file path:
\InvalidArgumentException When config pattern is not defined for the given route
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();
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);
$collection
->add($name, $route);
}