From 7432c29ffceb640b5c1c2d6ee9598ed8d07df933 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 27 Sep 2013 15:53:10 +0200 Subject: [PATCH] with doctrine, the routes are probably a Collection. reset() on a collection does not work --- ContentAwareGenerator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ContentAwareGenerator.php b/ContentAwareGenerator.php index a6fda995..32fe5367 100644 --- a/ContentAwareGenerator.php +++ b/ContentAwareGenerator.php @@ -2,6 +2,7 @@ namespace Symfony\Cmf\Component\Routing; +use Doctrine\Common\Collections\Collection; use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\RouteCollection; @@ -181,7 +182,11 @@ protected function getRouteByContent($name, &$parameters) return $route; } - // if none matched, continue and randomly return the first one + // if none matched, randomly return the first one + if ($routes instanceof Collection) { + return $routes->first(); + } + return reset($routes); }