Skip to content

Commit

Permalink
Merge remote branch 'lmcd/master'
Browse files Browse the repository at this point in the history
* lmcd/master:
  $code referenced but not defined in compileRoute()
  [Routing] Optimised the PHP URL matcher dumper The cached URL matcher classes contain some unneeded logic. Consider the following example:
  • Loading branch information
fabpot committed Jun 11, 2011
2 parents 9626f55 + 0b64207 commit c918f8e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Matcher/Dumper/PhpMatcherDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function match(\$pathinfo)
EOF;
}

private function compileRoutes(RouteCollection $routes, $supportsRedirections)
private function compileRoutes(RouteCollection $routes, $supportsRedirections, $parentPrefix = null)
{
$code = array();
foreach ($routes as $name => $route) {
Expand All @@ -82,7 +82,7 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections)
$indent = ' ';
}

foreach ($this->compileRoutes($route, $supportsRedirections) as $line) {
foreach ($this->compileRoutes($route, $supportsRedirections, $prefix) as $line) {
foreach (explode("\n", $line) as $l) {
$code[] = $indent.$l;
}
Expand All @@ -92,7 +92,7 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections)
$code[] = " }\n";
}
} else {
foreach ($this->compileRoute($route, $name, $supportsRedirections) as $line) {
foreach ($this->compileRoute($route, $name, $supportsRedirections, $parentPrefix) as $line) {
$code[] = $line;
}
}
Expand All @@ -101,8 +101,9 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections)
return $code;
}

private function compileRoute(Route $route, $name, $supportsRedirections)
private function compileRoute(Route $route, $name, $supportsRedirections, $parentPrefix = null)
{
$code = array();
$compiledRoute = $route->compile();
$conditions = array();
$hasTrailingSlash = false;
Expand All @@ -115,7 +116,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections)
$conditions[] = sprintf("\$pathinfo === '%s'", str_replace('\\', '', $m['url']));
}
} else {
if ($compiledRoute->getStaticPrefix()) {
if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() != $parentPrefix) {
$conditions[] = sprintf("0 === strpos(\$pathinfo, '%s')", $compiledRoute->getStaticPrefix());
}

Expand Down

0 comments on commit c918f8e

Please sign in to comment.