Skip to content
Browse files

[Routing] trigger deprecation warning for deprecated features that wi…

…ll be removed in 2.3
  • Loading branch information...
1 parent 6b4baba commit 9efa1448ef03275ea49c1835b696bf4f215c9e82 @Tobion Tobion committed
Showing with 18 additions and 1 deletion.
  1. +18 −1 RouteCollection.php
View
19 RouteCollection.php
@@ -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;
}
@@ -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();
@@ -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));
@@ -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());
@@ -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;
}

0 comments on commit 9efa144

Please sign in to comment.
Something went wrong with that request. Please try again.