Exemple #1
0
 public function testNamedRoutes()
 {
     $routes = new RouteCollection(new HttpMessageStrategy());
     $routes->addRoute('GET', '/user/{id}', function () {
     })->setName('UserProfile');
     $builder = new UrlBuilder(ServerRequestFactory::fromGlobals($this->fakeServerParams()), $routes);
     $this->assertEquals('/site/user/23', $builder->createByName('UserProfile', ['id' => 23]));
 }
Exemple #2
0
 /**
  *
  * @param string|array $httpMethod
  * @param string $route
  * @param mixed $handler
  * @param array $middlewares
  * @return RouteCollection
  */
 public function add($httpMethod, $route, $handler, $middlewares = [])
 {
     return $this->routes->addRoute($httpMethod, $route, $handler, $middlewares);
 }