Esempio n. 1
0
 public function testIfRouteTakesCareOfControllerSintax()
 {
     $route = new Route('test', 'HomeController@index');
     $this->assertEquals(['HomeController', 'index'], $route->getCallback());
     $route = new Route('test', function () {
     });
     $this->assertInstanceOf('Closure', $route->getCallback());
 }
 /**
  * Get and serve the controller
  *
  * @param Route $route
  * @return mixed
  * @throws \Exception
  */
 public function dispatch(Route $route)
 {
     $callback = $route->getCallback();
     $params = array_values($route->getData());
     if ($callback instanceof Closure) {
         return $this->container->resolveClosure($callback, $params);
     }
     $class = $this->container->make($callback[0]);
     return $this->container->resolveMethod($class, $callback[1], $params);
 }
Esempio n. 3
0
 /**
  * Set a pattern to the routes
  *
  * @param $name
  * @param $value
  */
 public function pattern($name, $value)
 {
     Route::pattern($name, $value);
 }