3
votes

Using Silex, how can I get the current Route object from inside a before filter? e.g.,

$app->before(function() use ($app) {
    // need to access Route for matched URL here
});

I need the whole object, not just the name.

1

1 Answers

4
votes

Not tested, but this should work.

$app->before(function(Request $req, Application $app) {
    $route = $app['routes']->get($req->get('_route'));
});

Just curious, why you need the Route object?