Exemplo n.º 1
0
 /**
  * Find the route that matches the current request
  *
  * @param Slab\Router\RouteCollection
  * @param Slab\Core\Http\RequestInterface
  * @return array Result
  **/
 public function findRoute(RouteCollection $routes, RequestInterface $request)
 {
     $dispatcher = new RouteDispatcher();
     $result = $dispatcher->dispatch($request, $routes);
     if ($result['status'] !== $dispatcher::FOUND) {
         return null;
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Test compiling patterns
  *
  * @param string Input path
  * @param string Compiled pattern
  * @param array Pattern keys
  * @return void
  * @dataProvider patternProvider
  **/
 public function testPatternCompiler($path, $test_pattern, $test_keys)
 {
     $dispatcher = new RouteDispatcher();
     list($pattern, $keys) = $dispatcher->compilePattern($path);
     $this->assertEquals($test_pattern, $pattern);
     $this->assertEquals($test_keys, array_keys($keys));
 }