Skip to content

Commit

Permalink
[Routing] trigger deprecation warning for deprecated features that wi…
Browse files Browse the repository at this point in the history
…ll be removed in 2.3
  • Loading branch information
Tobion committed Mar 5, 2013
1 parent 6c5a78a commit acff735
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Symfony/Component/Routing/RouteCollection.php
Expand Up @@ -65,6 +65,9 @@ public function __clone()
*/
public function getParent()
{
trigger_error('getParent() is deprecated since version 2.2 and will be removed in 2.3. There is no substitution ' .
'because RouteCollection is not tree structure anymore.', E_USER_DEPRECATED);

return $this->parent;
}

Expand All @@ -77,6 +80,9 @@ public function getParent()
*/
public function getRoot()
{
trigger_error('getRoot() is deprecated since version 2.2 and will be removed in 2.3. There is no substitution ' .
'because RouteCollection is not tree structure anymore.', E_USER_DEPRECATED);

$parent = $this;
while ($parent->getParent()) {
$parent = $parent->getParent();
Expand Down Expand Up @@ -184,6 +190,8 @@ public function addCollection(RouteCollection $collection)
// this is to keep BC
$numargs = func_num_args();
if ($numargs > 1) {
trigger_error('addCollection() should only be used with a single parameter. The params $prefix, $defaults, $requirements and $options ' .
'are deprecated since version 2.2 and will be removed in 2.3. Use addPrefix() and addOptions() instead.', E_USER_DEPRECATED);
$collection->addPrefix($this->prefix . func_get_arg(1));
if ($numargs > 2) {
$collection->addDefaults(func_get_arg(2));
Expand Down Expand Up @@ -232,7 +240,13 @@ public function addPrefix($prefix, array $defaults = array(), array $requirement
$this->prefix = '/' . $prefix . $this->prefix;

// this is to keep BC
$options = func_num_args() > 3 ? func_get_arg(3) : array();
if (func_num_args() > 3) {
trigger_error('The fourth parameter ($options) of addPrefix() is deprecated since version 2.2 and will be removed in 2.3. ' .
'Use addOptions() instead.', E_USER_DEPRECATED);
$options = func_get_arg(3);
} else {
$options = array();
}

foreach ($this->routes as $route) {
$route->setPath('/' . $prefix . $route->getPath());
Expand All @@ -251,6 +265,9 @@ public function addPrefix($prefix, array $defaults = array(), array $requirement
*/
public function getPrefix()
{
trigger_error('getPrefix() is deprecated since version 2.2 and will be removed in 2.3. The method suggests that ' .
'all routes in the collection would have this prefix, which is not necessarily true.', E_USER_DEPRECATED);

return $this->prefix;
}

Expand Down

0 comments on commit acff735

Please sign in to comment.