bcosca/fatfree — pull request #661 by xfra35 (2014-08-07 15:08:49+00:00)
Title: New ONREROUTE variable

This is a suggestion to answer issue #655. It is loose enough to fit other needs as well.

It's supposed to work like `ONERROR`, which means that the normal behaviour is not executed unless the return value is `FALSE`.

Examples of use with `$f3->mock()`:

In a test suite, in order to mock internal reroutes and ignore external ones:
```php
$f3->set('ONREROUTE',function($url,$permanent)use($f3){
if (!preg_match('/^http/',$url)
$f3->mock('GET '.$url);
});
$f3->mock(...);
```

In a test suite, in order to simulate the `die` effect of `$f3->reroute`:
```php
$f3->set('ONREROUTE',function($url,$permanent){
throw new StopRouteNow();//class StopRouteNow extends Exception {}
});
try {
$f3->mock(...);
} catch(StopRouteNow $e) {
//Route has been stopped;
} catch(Exception $e) {
//Real error here
}
```