示例#1
0
 /**
  * Expand resource handlers to routeset,
  * in here, we define how to expand RESTful URLs from resource id, 
  * and which is customizable.
  *
  * @param RouteSet $routes
  * @param string $r resource identifier.
  */
 static function expand($routes, $h, $r)
 {
     $class = is_object($h) ? get_class($h) : $h;
     $routes->add("/{$r}(.:format)", array($class, 'handleFind'), array('get' => true, 'default' => array('format' => 'json')));
     $routes->add('/' . $r . '(.:format)', array($class, 'handleCreate'), array('post' => true, 'default' => array('format' => 'json')));
     $routes->add('/' . $r . '/:id(.:format)', array($class, 'handleLoad'), array('get' => true, 'default' => array('format' => 'json')));
     $routes->add('/' . $r . '/:id(.:format)', array($class, 'handleUpdate'), array('put' => true, 'default' => array('format' => 'json')));
     $routes->add('/' . $r . '/:id(.:format)', array($class, 'handleDelete'), array('delete' => true, 'default' => array('format' => 'json')));
 }