Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Routing] simplified code

  • Loading branch information...
commit 45e34c29fd7e615b837aecd9f9acd865ff40f148 1 parent 794634d
@fabpot fabpot authored
View
25 src/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php
@@ -51,7 +51,6 @@ protected function addGenerator()
{
$methods = array();
$routes = array();
-
foreach ($this->routes->all() as $name => $route) {
$compiledRoute = $route->compile();
@@ -69,17 +68,19 @@ protected function get{$name}RouteInfo()
EOF
;
- $routes[$name] = true;
+ $routes[] = " '$name' => true,";
}
$methods = implode("\n", $methods);
- $routes = $this->exportParameters($routes);
+ $routes = implode("\n", $routes);
return <<<EOF
public function generate(\$name, array \$parameters, \$absolute = false)
{
- static \$routes = $routes;
+ static \$routes = array(
+$routes
+ );
if (!isset(\$routes[\$name])) {
throw new \InvalidArgumentException(sprintf('Route "%s" does not exist.', \$name));
@@ -133,20 +134,4 @@ protected function endClass()
EOF;
}
-
- protected function exportParameters($parameters, $indent = 12)
- {
- $php = array();
- foreach ($parameters as $key => $value) {
- if (is_array($value)) {
- $value = $this->exportParameters($value, $indent + 4);
- } else {
- $value = var_export($value, true);
- }
-
- $php[] = sprintf('%s%s => %s,', str_repeat(' ', $indent), var_export($key, true), $value);
- }
-
- return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4));
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.