/**
  * @param $router
  */
 private function setResolver($router)
 {
     if (!is_array($router['use'])) {
         $router['use'] = [$router['use']];
     }
     foreach ($router['use'] as $matcher) {
         /** @var MatcherInterface $class */
         $class = new $router['matcher'][$matcher]['class']($this->router);
         $class->setResolver($router['matcher'][$matcher]['resolver']);
         $this->router->addMatcher($class);
     }
 }
Exemple #2
0
 public function testGetResponseMethod()
 {
     $collection = new RouteCollection();
     $collection->addRoutes(ROOT . '/Config/routes.php', ['view_dir' => ROOT . '/Views', 'ctrl_namespace' => 'JetFire\\Routing\\App\\Controllers']);
     $router = new Router($collection);
     $router->addMatcher(new ArrayMatcher($router));
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $router->setUrl('/search');
     $this->assertFalse($router->match());
     $this->assertEquals(405, $router->response->getStatusCode());
 }