<?php $map = new SRouteSet(); $map->home('', array('controller' => 'home', 'action' => 'index')); $map->user_image('images/users/:filename', array('controller' => 'users', 'action' => 'generate_image', 'requirements' => array('filename' => '/[a-z0-9_]*$/'))); $map->achievement_image('images/achievements/:filename', array('controller' => 'achievements', 'action' => 'generate_image', 'requirements' => array('filename' => '/[0-9]*$/'))); $map->connect(':controller/:action/:id'); return $map;
function testControllerInSubdir() { $map = new SRouteSet(); $map->connect('process/:controller/:action/:id', array('subdirectory' => 'processing', 'controller' => 'images', 'action' => 'list')); $map->connect('cms/:controller/:action/:id', array('subdirectory' => 'content', 'controller' => 'articles')); $map->connect('admin/:controller/:action/:id', array('subdirectory' => 'admin')); $map->connect(':controller/:action/:id'); $this->setMap($map); $this->assertEqual(array('controller' => 'admin/users', 'action' => 'edit', 'id' => 15), $this->rec('admin/users/edit/15')); $this->assertEqual(array('controller' => 'content/photos', 'action' => 'edit', 'id' => 15), $this->rec('cms/photos/edit/15')); $this->assertEqual(array('controller' => 'content/articles'), $this->rec('cms')); $this->assertEqual(array('controller' => 'processing/images', 'action' => 'list'), $this->rec('process')); $this->assertEqual(array('controller' => 'processing/images', 'action' => 'list'), $this->rec('process/images')); $this->assertEqual(array('controller' => 'processing/images', 'action' => 'index'), $this->rec('process/images/index')); $this->assertEqual(array('controller' => 'processing/pdf', 'action' => 'generate', 'id' => 15), $this->rec('process/pdf/generate/15')); $this->assertEqual(array('admin/users/edit/15', array()), $this->gen(array('controller' => 'admin/users', 'action' => 'edit', 'id' => 15))); $this->assertEqual(array('cms/photos/edit/15', array()), $this->gen(array('controller' => 'content/photos', 'action' => 'edit', 'id' => 15))); $this->assertEqual(array('cms/articles/edit/15', array()), $this->gen(array('controller' => 'content/articles', 'action' => 'edit', 'id' => 15))); $this->assertEqual(array('cms', array()), $this->gen(array('controller' => 'content/articles'))); $this->assertEqual(array('cms', array()), $this->gen(array('controller' => 'content/articles', 'action' => 'index'))); $this->assertEqual(array('process', array()), $this->gen(array('controller' => 'processing/images', 'action' => 'list'))); $this->assertEqual(array('process/images/index', array()), $this->gen(array('controller' => 'processing/images', 'action' => 'index'))); }
<?php $map = new SRouteSet(); $map->connect(':controller/:action/:id'); return $map;