@@ -18,25 +18,19 @@ public function boot()
1818 {
1919 parent ::boot ();
2020
21- // When Lumen is running in the console there is no external request which means the service
22- // bindings for the request (Application::registerRequestBindings) are never run so the
23- // route resolver is never set. This is different from Laravel in that the route
24- // resolver is set once the route has been matched from the routing dispatcher.
25- // To get around this we'll watch for the rebinding of rebinding of the
26- // request object and simply use reflection to grab the currentRoute
27- // property and return it for the route resolver.
28- if ($ this ->app ->runningInConsole ()) {
29- $ this ->app ->rebinding ('Illuminate\Http\Request ' , function ($ app , $ request ) {
30- $ request ->setRouteResolver (function () use ($ app ) {
31- $ reflection = new ReflectionClass ($ app );
32-
33- $ property = $ reflection ->getProperty ('currentRoute ' );
34- $ property ->setAccessible (true );
35-
36- return $ property ->getValue ($ app );
37- });
21+ // Because Lumen sets the route resolver at a very weird point we're going to
22+ // have to use reflection whenever the request instance is rebound to
23+ // set the route resolver to get the current route.
24+ $ this ->app ->rebinding ('Illuminate\Http\Request ' , function ($ app , $ request ) {
25+ $ request ->setRouteResolver (function () use ($ app ) {
26+ $ reflection = new ReflectionClass ($ app );
27+
28+ $ property = $ reflection ->getProperty ('currentRoute ' );
29+ $ property ->setAccessible (true );
30+
31+ return $ property ->getValue ($ app );
3832 });
39- }
33+ });
4034
4135 $ this ->app ->routeMiddleware ([
4236 'api.auth ' => 'Dingo\Api\Http\Middleware\Auth ' ,
0 commit comments