peej/tonic — pull request #109 by lushchick (2012-09-04 14:25:27+00:00)
Title: Method name in before and after callbacks

Hey Paul,

I have a base Resource class (extended from Tonic\Resource) that all my resources extend from. I've decided to add @template annotation to my methods which would mean that response body in "after" callback should be passed to a template view and rendered.

So, in my BaseResource::template method i want to know the name of current method, to load its template, something like this:

```php
/**
* Process @template annotation by loading template file, rendering it and
* replacing response body with content
* @return void
*/
protected function template()
{
$app = $this->app;
$className = explode('\\', get_class($this));
$folder = strtolower(array_pop($className));

$this->after(function($res, $methodName) use ($app) {
if (is_array($res->body)) {
$res->body = $app->services['view']->render("$methodName.twig", $res->body);
}
});
}
```

I think someone would need the same functionality, so added additional parameter to before and after callbacks.