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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With