Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Routing] fixed previous merge
  • Loading branch information
fabpot committed Jun 25, 2012
1 parent db9a8c1 commit c67cf8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Symfony/Component/Routing/RouteCollection.php
Expand Up @@ -95,7 +95,12 @@ public function getIterator()
*/
public function count()
{
return count($this->routes->all());
$count = 0;
foreach ($this->routes as $route) {
$count += $route instanceof RouteCollection ? count($route) : 1;
}

This comment has been minimized.

Copy link
@stof

stof Jun 25, 2012

Member

what if a route is redefined using the same name to replace a previous route ?

This comment has been minimized.

Copy link
@fabpot

fabpot Jun 25, 2012

Author Member

it just works.

This comment has been minimized.

Copy link
@stof

stof Jun 25, 2012

Member

well, if they are in different collections, your new code will count them twice AFAICS whereas the previous one was taking care of the overwriting

This comment has been minimized.

Copy link
@fabpot

fabpot Jun 25, 2012

Author Member

The previous code did not worked at all as routes is an array, not an object. Whenever you override a route, the other ones with the same name are removed, so everything should work as expected.

This comment has been minimized.

Copy link
@stof

stof Jun 25, 2012

Member

ah yeah, I forgot that it is now removed directly when adding another route (it was not the case in 2.0)


return $count;
}

/**
Expand Down
Expand Up @@ -83,7 +83,7 @@ public function testCount()

$collection1 = new RouteCollection();
$collection->addCollection($collection1);
$collection1->add('foo', new Route('/foo1'));
$collection1->add('foo1', new Route('/foo1'));

$this->assertCount(2, $collection);
}
Expand Down

0 comments on commit c67cf8b

Please sign in to comment.