Ejemplo n.º 1
0
 public function testGetRouteWithParameters()
 {
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_SERVER['REQUEST_URI'] = '/index.php/blog/login/test@yes.com/success';
     // joke no get with login
     $this->routerConfig['blog']['login']['params']['get'] = 'email/password';
     $this->router->setRoutingConfig($this->routerConfig);
     $this->route->generate($this->router);
     $params = [0 => '*****@*****.**', 1 => 'success'];
     $this->assertEquals($this->route->getParams(), $params);
 }
Ejemplo n.º 2
0
 public function route()
 {
     $route = new Route();
     $uri = $_SERVER['REQUEST_URI'];
     $route->generate($this);
     //    Components::getInstance()->get('logger')->log('$route', $route);
     $routeSettings = $this->routingConfig[$route->getSubject()][$route->getAction()];
     //    Components::getInstance()->get('logger')->log('$route->getSubject()', $route->getSubject());
     //    Components::getInstance()->get('logger')->log('$route->getAction()', $route->getAction());
     //    Components::getInstance()->get('logger')->log('$routeSettings', $routeSettings);
     $class = $routeSettings['class'];
     $obj = new $class();
     //    Components::getInstance()->get('logger')->log('$route', $route);
     if (isset($routeSettings['rest']) && $routeSettings['rest']) {
         $action = $route->getAction();
         $obj->{$action}($route->getParams());
     } else {
         call_user_func_array(array($obj, $route->getAction()), $route->getParams());
     }
 }