8000 [Routing] fixed several bugs and applied improvements by Tobion · Pull Request #3754 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] fixed several bugs and applied improvements #3754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixed CS and added notes in changelog
  • Loading branch information
Tobion committed Apr 11, 2012
commit a6b8d54c6723dec610fda70aaad7fa34376e7a50
8 changes: 5 additions & 3 deletions CHANGELOG-2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,11 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
* added a TraceableUrlMatcher
* added the possibility to define options, default values and requirements for placeholders in prefix, including imported routes
* added RouterInterface::getRouteCollection
* [BC BREAK] the UrlMatcher urldecodes the route parameters only once, they were
decoded twice before. Note that the `urldecode()` calls have been change for a
single `rawurldecode()` in order to support `+` for input paths.
* [BC BREAK] the UrlMatcher urldecodes the route parameters only once, they were decoded twice before.
Note that the `urldecode()` calls have been changed for a single `rawurldecode()` in order to support `+` for input paths.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed typo there: changed
@stof I rebased. Btw, how do I rebase and resolve conflict without using the --force option when pushing? Without it, it gets rejected becaues of non-fast-forward updates.

Copy link
Member

Choose a reason for hiding this comment

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

@Tobion when you rebase, you need to use --force when pushing as rebasing rewrites the history.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. The problem is github puts all commits at the end after that in Tobion added some commits section.
So conversation history is not that easy to follow.

Copy link

Choose a reason for hiding this comment

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

For reference there is also another syntax git push tobion +branch_name which also forces the write.

* added RouteCollection::getRoot method to retrieve the root of a RouteCollection tree
* [BC BREAK] made RouteCollection::setParent private which could not have been used anyway without creating inconsistencies
* [BC BREAK] RouteCollection::remove also removes a route from parent collections (not only from its children)

### Security

Expand Down
21 changes: 7 additions & 14 deletions src/Symfony/Component/Routing/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public function all()
/**
* Gets a route by name defined in this collection or its children.
*
* @param string $name The route name
* @param string $name The route name
*
* @return Route|null $route A Route instance or null when not found
* @return Route|null A Route instance or null when not found
*/
public function get($name)
{
Expand All @@ -160,12 +160,8 @@ public function remove($name)
{
$root = $this->getRoot();

if (is_array($name)) {
foreach ($name as $n) {
$root->removeRecursively($n);
}
} else {
$root->removeRecursively($name);
foreach ((array) $name as $n) {
$root->removeRecursively($n);
}
}

Expand All @@ -186,7 +182,7 @@ public function addCollection(RouteCollection $collection, $prefix = '', $defaul
{
// prevent infinite loops by recursive referencing
$root = $this->getRoot();
if ($root === $collection || $root->existsSubCollection($collection)) {
if ($root === $collection || $root->hasCollection($collection)) {
throw new \InvalidArgumentException('The RouteCollection already exists in the tree.');
}

Expand Down Expand Up @@ -321,13 +317,10 @@ private function removeRecursively($name)
*
* @return Boolean
*/
private function existsSubCollection(RouteCollection $collection)
private function hasCollection(RouteCollection $collection)
{
foreach ($this->routes as $routes) {
if ($routes === $collection) {
return true;
}
if ($routes instanceof RouteCollection && $routes->existsSubCollection($collection)) {
if ($routes === $collection || $routes instanceof RouteCollection && $routes->hasCollection($collection)) {
return true;
}
}
Expand Down
0