[Routing] trigger deprecation warning for deprecated features that will be removed in 2.3

This commit is contained in:
Tobias Schultze 2013-03-05 12:07:44 +01:00
parent 6c5a78ad8c
commit acff7356ce
1 changed files with 18 additions and 1 deletions

View File

@ -65,6 +65,9 @@ class RouteCollection implements \IteratorAggregate, \Countable
*/
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;
}
@ -77,6 +80,9 @@ class RouteCollection implements \IteratorAggregate, \Countable
*/
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();
@ -184,6 +190,8 @@ class RouteCollection implements \IteratorAggregate, \Countable
// 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));
@ -232,7 +240,13 @@ class RouteCollection implements \IteratorAggregate, \Countable
$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());
@ -251,6 +265,9 @@ class RouteCollection implements \IteratorAggregate, \Countable
*/
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;
}