protected function YamlFileLoader::parseRoute

Parses a route and adds it to the RouteCollection.

Parameters

RouteCollection $collection A RouteCollection instance:

string $name Route name:

array $config Route definition:

string $file A Yaml file path:

Throws

\InvalidArgumentException When config pattern is not defined for the given route

1 call to YamlFileLoader::parseRoute()
YamlFileLoader::load in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php
Loads a Yaml file.

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php, line 104

Class

YamlFileLoader
YamlFileLoader loads Yaml routing files.

Namespace

Symfony\Component\Routing\Loader

Code

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);
}