Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/Symfony/Component/Routing/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,8 @@ public function get(string $name)
*/
public function remove($name)
{
$names = (array) $name;
foreach ($names as $n) {
unset($this->routes[$n], $this->priorities[$n]);
}

foreach ($this->aliases as $k => $alias) {
if (\in_array($alias->getId(), $names, true)) {
unset($this->aliases[$k]);
}
foreach ((array) $name as $n) {
unset($this->routes[$n], $this->priorities[$n], $this->aliases[$n]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing something here, but why not have this method remove both an alias, if it's an alias, or a route with all its aliases, if it's a route?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wondered the same. That'd make sense to me.

}
}

Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Routing/Tests/RouteCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,11 @@ public function testRemove()
$collection1->add('bar', $bar = new Route('/bar'));
$collection->addCollection($collection1);
$collection->add('last', $last = new Route('/last'));
$collection->addAlias('ccc_my_custom_alias', 'foo');

$collection->remove('foo');
$this->assertSame(['bar' => $bar, 'last' => $last], $collection->all(), '->remove() can remove a single route');
$collection->remove(['bar', 'last']);
$this->assertSame([], $collection->all(), '->remove() accepts an array and can remove multiple routes at once');
$this->assertNull($collection->getAlias('ccc_my_custom_alias'));
}

public function testSetHost()
Expand Down