public static function expand()
 {
     $class = get_called_class();
     $routeset = new \Roller\RouteSet();
     $routeset->add('/', $class . ':indexAction');
     $routeset->add('/collection.json', $class . ':jsonAction');
     $routeset->add('/collection.yml', $class . ':yamlAction');
     return $routeset;
 }
Esempio n. 2
0
 function test()
 {
     $routes = new Roller\RouteSet();
     $routes->add('/blog/:year/:month', function () {
         return 'Yes';
     }, array('year' => '\\d'));
     $routes->compile();
     $dumper = new Roller\Dumper\ConsoleDumper();
     ob_start();
     $dumper->dump($routes);
     ob_end_clean();
 }
Esempio n. 3
0
 function testPHPDumper()
 {
     $routes1 = new Roller\RouteSet();
     $routes2 = new Roller\RouteSet();
     $routes1->add('/item', function () {
         return 'item';
     });
     $routes2->add('/subitem', function () {
         return 'subitem';
     });
     $routes1->mount('/item', $routes2);
     $dumper = new Roller\Dumper\PhpDumper();
     $code = $dumper->dump($routes1);
     $cRoutes = eval($code);
     $router = new Roller\Router($cRoutes);
     $r = $router->dispatch('/item');
     is('item', $r());
     $r = $router->dispatch('/item/subitem');
     is('subitem', $r());
 }
Esempio n. 4
0
<?php

require 'tests/bootstrap.php';
$routes = new Roller\RouteSet();
$routes->add('/blog/:year/:month', function ($year, $month) {
    return 'Yes';
}, array('year' => '\\d+'));
$routes->add('/blog/:id', function ($id) {
    return $id;
}, array('id' => '\\d+'));
$routes->compile();
$dumper = new Roller\Dumper\ConsoleDumper();
$dumper->dump($routes);