private function PhpGeneratorDumper::generateDeclaredRoutes

Generates PHP code representing an array of defined routes together with the routes properties (e.g. requirements).

Return value

string PHP code

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php, line 85

Class

PhpGeneratorDumper
PhpGeneratorDumper creates a PHP class able to generate URLs for a given set of routes.

Namespace

Symfony\Component\Routing\Generator\Dumper

Code

private function generateDeclaredRoutes() {
  $routes = "array(\n";
  foreach ($this
    ->getRoutes()
    ->all() as $name => $route) {
    $compiledRoute = $route
      ->compile();
    $properties = array();
    $properties[] = $compiledRoute
      ->getVariables();
    $properties[] = $route
      ->getDefaults();
    $properties[] = $route
      ->getRequirements();
    $properties[] = $compiledRoute
      ->getTokens();
    $routes .= sprintf("        '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true)));
  }
  $routes .= '    )';
  return $routes;
}