Skip to content

Commit 2a5cc82

Browse files
committed
Merge pull request #83 from symfony-cmf/handle-doctrine-collections
with doctrine, the routes are probably a Collection. reset() on a collection does not work
2 parents 3e722db + 7432c29 commit 2a5cc82

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ContentAwareGenerator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Symfony\Cmf\Component\Routing;
44

5+
use Doctrine\Common\Collections\Collection;
56
use Symfony\Component\Routing\Route as SymfonyRoute;
67
use Symfony\Component\Routing\Exception\RouteNotFoundException;
78
use Symfony\Component\Routing\RouteCollection;
@@ -181,7 +182,11 @@ protected function getRouteByContent($name, &$parameters)
181182
return $route;
182183
}
183184

184-
// if none matched, continue and randomly return the first one
185+
// if none matched, randomly return the first one
186+
if ($routes instanceof Collection) {
187+
return $routes->first();
188+
}
189+
185190
return reset($routes);
186191
}
187192

0 commit comments

Comments
 (0)