Esempio n. 1
0
function routesFunction(FastRoute\RouteCollector $r)
{
    //Category indices
    $r->addRoute('GET', "/", ['JigDemo\\Controller\\Index', 'display']);
    $r->addRoute('GET', "/bindingDataExample", ['JigDemo\\Controller\\BindingDataExample', 'display']);
    $r->addRoute('GET', "/extend", ['JigDemo\\Controller\\Extend', 'display']);
    $r->addRoute('GET', "/reuseExample", ['JigDemo\\Controller\\ReuseExample', 'display']);
    $r->addRoute('GET', "/functionExample", ['JigDemo\\Controller\\FunctionExample', 'display']);
    $r->addRoute('GET', "/blockExample", ['JigDemo\\Controller\\BlockExample', 'display']);
    $r->addRoute('GET', "/syntaxExample", ['JigDemo\\Controller\\SyntaxExample', 'display']);
}
Esempio n. 2
0
/**
 * Helper function to bind the route list to FastRoute
 * @param \FastRoute\RouteCollector $r
 */
function routesFunction(FastRoute\RouteCollector $r)
{
    $r->addRoute('GET', "/", ['TierTest\\Controller\\BasicController', 'helloWorld']);
    $r->addRoute('GET', "/instantiateUnknownClass", ['TierTest\\Controller\\BasicController', 'instantiateUnknownClass']);
    $r->addRoute('GET', "/throwException", ['TierTest\\Controller\\BasicController', 'throwException']);
    $r->addRoute('GET', "/unknownDependency", ['TierTest\\Controller\\BasicController', 'unknownDependency']);
    $r->addRoute('GET', '/cleanupException', ['TierTest\\Controller\\BasicController', 'testOutputBufferingIsCleared']);
    $r->addRoute('GET', '/renderTemplateExecutable', ['TierTest\\Controller\\BasicController', 'renderTemplateExecutable']);
}
 public function testUsingCustomDispatcher()
 {
     $routes = new FastRoute\RouteCollector(new FastRoute\RouteParser\Std(), new FastRoute\DataGenerator\GroupCountBased());
     $routes->addRoute('GET', '/', [function () {
         return response('Hello World');
     }]);
     $app = new Application();
     $app->setDispatcher(new FastRoute\Dispatcher\GroupCountBased($routes->getData()));
     $response = $app->handle(Request::create('/', 'GET'));
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('Hello World', $response->getContent());
 }
Esempio n. 4
0
 /**
  * @param FastRoute\RouteCollector $router
  */
 protected function getRoutes(FastRoute\RouteCollector $router)
 {
     $routes = $this->routes;
     if (!$routes) {
         throw new InvalidArgumentException('Invalid routes');
     }
     foreach ($routes as $r) {
         $router->addRoute($r[0], $r[1], $r[2]);
     }
 }