OSDN Git Service

Fix the error on load routers from a Yaml file #33
authorJefersson Nathan <admin@phpse.net>
Wed, 25 Jun 2014 16:24:37 +0000 (13:24 -0300)
committerJefersson Nathan <admin@phpse.net>
Wed, 25 Jun 2014 16:24:37 +0000 (13:24 -0300)
- Fix indentation on RouteCollection
- Fix load from yaml described routers

src/PHPRouter/RouteCollection.php
src/PHPRouter/Router.php

index e77f5a7..eaddd41 100755 (executable)
@@ -8,14 +8,14 @@ class RouteCollection extends \SplObjectStorage
      * and return it.\r
      *\r
      * @return array\r
-     */ \r
+     */\r
     public function all()\r
     {\r
-       $_tmp = array();\r
+        $_tmp = array();\r
         foreach($this as $objectValue)\r
-       {\r
-           $_tmp[] = $objectValue;\r
-       }\r
-       return $_tmp;\r
+        {\r
+            $_tmp[] = $objectValue;\r
+        }\r
+        return $_tmp;\r
     }\r
 }\r
index b4d3621..aa0d5f6 100755 (executable)
@@ -12,12 +12,12 @@ class Router
     /**
     * Array that holds all Route objects
     * @var array
-    */ 
+    */
     private $_routes = array();
 
     /**
      * Array to store named routes in, used for reverse routing.
-     * @var array 
+     * @var array
      */
     private $_namedRoutes = array();
 
@@ -154,7 +154,7 @@ class Router
     {
         $collection = new RouteCollection();
         foreach ($config['routes'] as $name => $route) {
-            $collection->add($name, new Route($route[0], array(
+            $collection->attach($name, new Route($route[0], array(
                 '_controller' => str_replace('.', '::', $route[1]),
                 'methods' => $route[2]
             )));