You are here

private function PhpGeneratorDumper::generateDeclaredRoutes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php \Symfony\Component\Routing\Generator\Dumper\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

vendor/symfony/routing/Generator/Dumper/PhpGeneratorDumper.php, line 79

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();
    $properties[] = $compiledRoute
      ->getHostTokens();
    $properties[] = $route
      ->getSchemes();
    $routes .= sprintf("        '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true)));
  }
  $routes .= '    )';
  return $routes;
}