Browse Source

Allow method chaining for add methods

Joost Farla 12 years ago
parent
commit
fb57d1f033
1 changed files with 7 additions and 1 deletions
  1. 7 1
      Route/RouteCollection.php

+ 7 - 1
Route/RouteCollection.php

@@ -45,7 +45,7 @@ class RouteCollection
      * @param array  $requirements
      * @param array  $requirements
      * @param array  $options
      * @param array  $options
      *
      *
-     * @return void
+     * @return \Sonata\AdminBundle\Route\RouteCollection
      */
      */
     public function add($name, $pattern = null, array $defaults = array(), array $requirements = array(), array $options = array())
     public function add($name, $pattern = null, array $defaults = array(), array $requirements = array(), array $options = array())
     {
     {
@@ -64,6 +64,8 @@ class RouteCollection
         $defaults['_sonata_name'] = $routeName;
         $defaults['_sonata_name'] = $routeName;
 
 
         $this->elements[$this->getCode($name)] = new Route($pattern, $defaults, $requirements, $options);
         $this->elements[$this->getCode($name)] = new Route($pattern, $defaults, $requirements, $options);
+
+        return $this;
     }
     }
 
 
     /**
     /**
@@ -82,12 +84,16 @@ class RouteCollection
 
 
     /**
     /**
      * @param RouteCollection $collection
      * @param RouteCollection $collection
+     *
+     * @return \Sonata\AdminBundle\Route\RouteCollection
      */
      */
     public function addCollection(RouteCollection $collection)
     public function addCollection(RouteCollection $collection)
     {
     {
         foreach ($collection->getElements() as $code => $route) {
         foreach ($collection->getElements() as $code => $route) {
             $this->elements[$code] = $route;
             $this->elements[$code] = $route;
         }
         }
+
+        return $this;
     }
     }
 
 
     /**
     /**