8000 [Routing] clean up of RouteCollection API by Tobion · Pull Request #6022 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] clean up of RouteCollection API #6022

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 11 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
deprecated RouteCollection::getPrefix
  • Loading branch information
Tobion committed Dec 7, 2012
commit e4d58caede520110c1f1cfc441e073fb76d2bb01
5 changes: 5 additions & 0 deletions src/Symfony/Component/Routing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ CHANGELOG
* [DEPRECATION] The `$options` parameter to `RouteCollection::addPrefix()` has been deprecated
because adding options has nothing to do with adding a path prefix. If you want to add options
to all child routes of a RouteCollection, you can use `addOptions()`.
* [DEPRECATION] The method `RouteCollection::getPrefix()` has been deprecated
because it suggested that all routes in the collection would have this prefix, which is
not necessarily true. On top of that, since there is no tree structure anymore, this method
is also useless. Don't worry about performance, prefix optimization for matching is still done
in the dumper, which was also improved in 2.2.0 to find even more grouping possibilities.
* [DEPRECATION] `RouteCollection::addCollection(RouteCollection $collection)` should now only be
used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
will still work, but have been deprecated. The `addPrefix` method should be used for this
Expand Down
8 changes: 6 additions & 2 deletions src/Symfony/Component/Routing/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class RouteCollection implements \IteratorAggregate, \Countable

/**
* @var string
* @deprecated since version 2.2, will be removed in 2.3
Copy link
Member

Choose a reason for hiding this comment

The reas 8000 on will be displayed to describe this comment to others. Learn more.

I would remove this as the var is private anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The private $parent is also annotated. And this is basically only a reminder, that we don't need to save the prefix anymore in 2.3 (additionally to removing getPrefix)

*/
private $prefix = '';

Expand Down Expand Up @@ -183,7 +184,7 @@ public function addCollection(RouteCollection $collection)
// this is to keep BC
$numargs = func_num_args();
if ($numargs > 1) {
$collection->addPrefix($this->getPrefix() . func_get_arg(1));
$collection->addPrefix($this->prefix . func_get_arg(1));
if ($numargs > 2) {
$collection->addDefaults(func_get_arg(2));
if ($numargs > 3) {
Expand All @@ -196,7 +197,8 @@ public function addCollection(RouteCollection $collection)
} else {
// the sub-collection must have the prefix of the parent (current instance) prepended because it does not
// necessarily already have it applied (depending on the order RouteCollections are added to each other)
$collection->addPrefix($this->getPrefix());
// this will be removed when the BC layer for getPrefix() is removed
$collection->addPrefix($this->prefix);
}

// we need to remove all routes with the same names first because just replacing them
Expand Down Expand Up @@ -244,6 +246,8 @@ public function addPrefix($prefix, array $defaults = array(), array $requirement
* Returns the prefix that may contain placeholders.
*
* @return string The prefix
*
* @deprecated since version 2.2, will be removed in 2.3
*/
public function getPrefix()
{
Expand Down
0