コード例 #1
0
ファイル: RouteTest.php プロジェクト: Mosaic/Mosaic
 public function test_action_gets_transformed_to_array()
 {
     $route = new Route(['GET'], '/', function () {
     });
     $this->assertTrue(is_array($route->action()));
     $this->assertTrue(isset($route->action()['uses']));
     $this->assertTrue(is_callable($route->action()['uses']));
     $route = new Route(['GET'], '/', 'HomeController@index');
     $this->assertTrue(is_array($route->action()));
     $this->assertTrue(isset($route->action()['uses']));
     $this->assertEquals('HomeController@index', $route->action()['uses']);
     $route = new Route(['GET'], '/', ['uses' => 'HomeController@index']);
     $this->assertTrue(is_array($route->action()));
     $this->assertTrue(isset($route->action()['uses']));
     $this->assertEquals('HomeController@index', $route->action()['uses']);
 }
コード例 #2
0
ファイル: DispatchController.php プロジェクト: Mosaic/Mosaic
 /**
  * Dispatch the request
  *
  * @param Route $route
  *
  * @throws NotFoundHttpException
  * @return mixed
  */
 public function dispatch(Route $route)
 {
     $action = $route->action();
     list($class, $method) = explode('@', $action['uses']);
     if (!method_exists($instance = $this->container->make($class), $method)) {
         throw new NotFoundHttpException();
     }
     $parameters = $this->resolver->resolve(new ReflectionMethod($instance, $method), $route->parameters());
     return $this->container->call([$instance, $method], $parameters);
 }
コード例 #3
0
ファイル: DispatchClosure.php プロジェクト: Mosaic/Mosaic
 /**
  * @param Route $route
  *
  * @return bool
  */
 public function isSatisfiedBy(Route $route)
 {
     $action = $route->action();
     return is_callable($action['uses']);
 }