Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

handle class name for RESTful handler.

  • Loading branch information...
commit 897dad858f0b78eb58647e93823660b4bf6f682a 1 parent eaff515
@c9s authored
View
7 roller_xhprof.php
@@ -8,6 +8,7 @@
// do something here
$router = new Roller\Router( null, array(
'cache_id' => 'roller_xhprof',
+ 'cache_dir' => 'cache',
));
$restful = new Roller\Plugin\RESTful(array( 'prefix' => '/restful' ));
$restful->registerResource( 'blog' , 'BlogResourceHandler' );
@@ -19,12 +20,10 @@
// stop profiler
$xhprof_data = xhprof_disable();
-$XHPROF_ROOT = '/Users/c9s/git/others/facebook/xhprof';
-
// Saving the XHProf run
// using the default implementation of iXHProfRuns.
-include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
-include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
+include_once "xhprof_lib/utils/xhprof_lib.php";
+include_once "xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
View
12 src/Roller/Plugin/RESTful/GenericHandler.php
@@ -44,27 +44,29 @@ public function handleDelete($resource,$id,$format)
public function expand($routes, $h)
{
- $routes->add( '/:resource(\.:format)' , array( $h , 'handleCreate' ), array(
+ $class = is_object($h) ? get_class($h) : $h;
+
+ $routes->add( '/:resource(\.:format)' , array( $class , 'handleCreate' ), array(
':method' => 'post',
':default' => array( 'format' => 'json' ),
));
- $routes->add( '/:resource(\.:format)' , array( $h , 'handleFind' ), array(
+ $routes->add( '/:resource(\.:format)' , array( $class , 'handleFind' ), array(
':method' => 'get',
':default' => array( 'format' => 'json' ),
));
- $routes->add( '/:resource/:id(\.:format)' , array( $h, 'handleUpdate'), array(
+ $routes->add( '/:resource/:id(\.:format)' , array( $class, 'handleUpdate'), array(
':method' => 'put',
':default' => array( 'format' => 'json' ),
));
- $routes->add( '/:resource/:id(\.:format)' , array( $h, 'handleDelete'), array(
+ $routes->add( '/:resource/:id(\.:format)' , array( $class, 'handleDelete'), array(
':method' => 'delete',
':default' => array( 'format' => 'json' ),
));
- $routes->add( '/:resource/:id(\.:format)' , array( $h, 'handleLoad'), array(
+ $routes->add( '/:resource/:id(\.:format)' , array( $class, 'handleLoad'), array(
':method' => 'get',
':default' => array( 'format' => 'json' ),
));
View
11 src/Roller/Plugin/RESTful/ResourceHandler.php
@@ -45,31 +45,32 @@
*/
public function expand($routes, $h, $r)
{
- $routes->add( "/$r(\.:format)" , array($h,'handleFind'),
+ $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($h,'handleCreate'),
+ $routes->add( '/' . $r . '(\.:format)' , array($class,'handleCreate'),
array(
':post' => true,
':default' => array( 'format' => 'json' )
));
- $routes->add( '/' . $r . '/:id(\.:format)' , array($h,'handleLoad'),
+ $routes->add( '/' . $r . '/:id(\.:format)' , array($class,'handleLoad'),
array(
':get' => true,
':default' => array( 'format' => 'json' )
));
- $routes->add( '/' . $r . '/:id(\.:format)' , array($h,'handleUpdate'),
+ $routes->add( '/' . $r . '/:id(\.:format)' , array($class,'handleUpdate'),
array(
':put' => true,
':default' => array( 'format' => 'json' )
));
- $routes->add( '/' . $r . '/:id(\.:format)' , array($h,'handleDelete'),
+ $routes->add( '/' . $r . '/:id(\.:format)' , array($class,'handleDelete'),
array(
':delete' => true,
':default' => array( 'format' => 'json' )
Please sign in to comment.
Something went wrong with that request. Please try again.