autarky/framework — pull request #39 by anlutro (2014-10-11 07:12:21+00:00)
Title: Convert route filters into event listeners

#### Event methods

`getRequest()`, `getRoute()` are available on all events.

"before" events also have `setResponse(mixed $response)` and `setController(callable $controller)`.

"after" events have `setResponse(Response $response)`.

#### Replacing responses in before filters

Before:

```php
$router->defineFilter('foo', function() { return 'filter response'; });
```

After:

```php
$router->addBeforeFilter('foo', function($event) {
$event->setResponse('filter response');
});
```

### Replacing the controller with a custom responder

Before:

```php
class MyFilter {
public function filter() {
return true;
}
}

class MyResponder {
public function respond() {
return 'filter response';
}
}

$router->defineFilter('foo', ['MyFilter:filter', 'MyResponder:respond']);
```

After:

```php
class MyResponder {
public function respond() {
return 'filter response';
}
}

$router->addBeforeFilter('foo', function($event) {
$event->setController(['MyResponder', 'respond']);
});
```